J
James
Hello,
We've been given a program that reads data from a .dat file. It looks
something like this:
1 1.0 1.2
2 2.4 3.5
3 3.4 6.5
4 3.3 2.2
....and so on. I need to know a way of preinting this on screen - i can
do this easily for a file of known size, i have a statement like:
fprintf(stdout, "%d %lf %lf", node_array[no_nodes-1].id,
node_array[no_nodes-1].x, node_array[no_nodes-1].y);
where i can replace the "-1" with "-n". However, seeing as the arrays
are of a length anywhere between 1 and 100 lines long, well, theres
got to be a better way of doing it! Otherwise, any array less than 100
structures long will have a lot of rubbish printed out. Oh course you
knew that - I'm very new at C, so I'm being obvious for my own
understanding!
Any help would be very much appreciated!
James Brennan - Craddock
We've been given a program that reads data from a .dat file. It looks
something like this:
1 1.0 1.2
2 2.4 3.5
3 3.4 6.5
4 3.3 2.2
....and so on. I need to know a way of preinting this on screen - i can
do this easily for a file of known size, i have a statement like:
fprintf(stdout, "%d %lf %lf", node_array[no_nodes-1].id,
node_array[no_nodes-1].x, node_array[no_nodes-1].y);
where i can replace the "-1" with "-n". However, seeing as the arrays
are of a length anywhere between 1 and 100 lines long, well, theres
got to be a better way of doing it! Otherwise, any array less than 100
structures long will have a lot of rubbish printed out. Oh course you
knew that - I'm very new at C, so I'm being obvious for my own
understanding!
Any help would be very much appreciated!
James Brennan - Craddock