F
Fallon
If someone could help it would be greatly appreciated.
I am trying to write a simple program to read in elements from an
input file formatted as follows:
3
4
81
5
6
45
54
7
..
..
..
(etc)
Now I'd like to be able to extract the first, third, or any ordered
element?
How would I do this, I've looked at all documentation for fscanf and
haven't been able to find the answer. I know I can read in the first
element using:
fscanf(fd, "%d", &x)
Or the entire list can be read in using a for loop of something like:
for(i=0; i < number; i++)
if (fscanf(fd, "%d", &x)==EOF)
break;
But how can I access specific ordered elements, or for that matter a
specific range of elements from the input file (e.g. elements 4-8)?
Much appreciated,
Jessica
I am trying to write a simple program to read in elements from an
input file formatted as follows:
3
4
81
5
6
45
54
7
..
..
..
(etc)
Now I'd like to be able to extract the first, third, or any ordered
element?
How would I do this, I've looked at all documentation for fscanf and
haven't been able to find the answer. I know I can read in the first
element using:
fscanf(fd, "%d", &x)
Or the entire list can be read in using a for loop of something like:
for(i=0; i < number; i++)
if (fscanf(fd, "%d", &x)==EOF)
break;
But how can I access specific ordered elements, or for that matter a
specific range of elements from the input file (e.g. elements 4-8)?
Much appreciated,
Jessica