read one line of input from file and then destroying it!

W

waffle.horn

Hi,

if this makes sense i want to create a function that can be called so
that it reads a single line from a file, then after using the
information destroys it. Such that when the function is called that
line of info does not exist anymore in the file.

for example i have created a short example of where i am at, but I
dont know how to alter what im doing so that i just read in a single
line

while (fgets(line, STRING_LENGTH, obs_fp) != NULL) {
d->projectday++;

if(sscanf(line, "%d %lf %lf", &(d->yearday), &(d->temp), &(d-
maxt[k])) != 3) {
fprintf(stderr, "%s: badly formatted input in file: %s on line %d
\n", *argv, obs_fn, (int)k+1);
exit(1);
}



d->trange[k] = 0.5 * (d->maxt - d->mint);
k++;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top