I have a file named config.txt
which has following data
1 2 3 4
|
//config.txt
Number of node = 11
Link delay = 1 2 3 4 5 6 7 8 9 10
|
now I want to read config.txt from command pronpt
also I want to read number of nodes from config.txt and I want to use it for calculation of delay between nodes.
as follows
1 2 3 4 5 6 7 8 9
|
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);
}
|
I have 11 nodes.
link delay between node 1 and node 2 is 2
link delay berween node 2 and node 3 is 2
and so on.
please help in solving this
But I do not know hoe to read data from file and how to use it fro computation
please reply
Last edited on