LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
 
Search this Thread
Old 03-02-2014, 08:07 AM   #1
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Rep: Reputation: Disabled
readArgFromFile’ was not declared in this scope


Hello friends

I tried following example to calculate different delay between nodes

first I created a file named config.txt which has values

Code:
//config.txt
 Number of node = 11
 Link delay = 1 2 3 4 5 6 7 8 9 10
next a cc program to calculated link delay

Code:
//sim.cc
#include<stdlib.h> 
#include <iostream>
#include <fstream>
#include <math.h>
#include <cstdio>

 int main(int argc, char* argv[]) {
 float delay = 0, d[10];
 FILE* fp = fopen(argv[1],"w");
 int i, num_nodes = readArgFromFile(fp,d);
 for(i = 1; i < num_nodes; i++)
 delay += d[i-1];
 printf("Overall Packet Delay is %2.1f seconds\n",
delay);
 fclose(fp);
 }
when I try to compile the program s follows
[code]
g++ -o sim sim.cc
i got error
Code:
In function ‘int main(int, char**)’:
sim.cc:10: error: ‘readArgFromFile’ was not declared in this scope
 
Old 03-02-2014, 08:28 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 723

Rep: Reputation: 297Reputation: 297Reputation: 297
What's readArgFromFile? Where is it defined?

Last edited by millgates; 03-02-2014 at 08:46 AM.
 
Old 03-02-2014, 09:01 AM   #3
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Original Poster
Rep: Reputation: Disabled
Thanks for reply

I have taken this example from book Introduction to NS-2
Teerwat_Issariyakul

I do not know how to read arguments from text file. and how to use them in c++
I have to read number of nodes from txt file and also link delay between them
 
Old 03-02-2014, 09:37 AM   #4
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 723

Rep: Reputation: 297Reputation: 297Reputation: 297
As far as I know, there is no such function in any of the standard C++ libraries. Either the book you are reading provides its definition, or you'll have to implement it yourself. For reading from files, you'll need either methods from fstream (alternatively, you may use the old style plain C cstdio).

If you're unsure about how to do this, I strongly recommend that you familiarise yourself with the basics of C++ (the sticky thread here in the programming section has a lot of resources for learning C/C++) before continuing with your book.
 
1 members found this post helpful.
Old 03-02-2014, 11:12 PM   #5
Aska123
Member
 
Registered: Apr 2013
Posts: 197

Original Poster
Rep: Reputation: Disabled
Ok millgates
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting `__LOCK_INITIALIZER' was not declared in this scope error Divya Sankaran Linux - Newbie 1 02-03-2012 09:33 PM
[SOLVED] error: 'memset' in not declared in this scope isaacjun16 Ubuntu 3 10-01-2010 04:22 PM
[SOLVED] ‘GTK_TEXT’ was not declared in this scope nainesh Programming 10 09-20-2010 12:51 AM
Error Prompt - 'Execute_command was not declared in this scope. Please help! thhuang Linux - Newbie 1 11-05-2007 12:38 AM
ltoa not declared in the scope lucky6969b Programming 3 12-23-2005 08:44 AM


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration