O
Oliver Knoll
According to my ANSI book, tmpfile() creates a file with wb+ mode
(that is just writing, right?). How would one reopen it for reading?
I got the following (which works):
FILE *tmpFile = tmpfile();
/* write into tmpFile */
...
/* is this correct? */
rewind (tmpFile);
while (fgets (line, MAXSIZE, tmpFile) {
/* put content of tmpFile into another file /*
...
}
Does rewind change the mode? Or why am I able to read from the tmpFile
this way? (I've seen in other posts that other people use rewind as
well this way).
Thanks, Oliver
(that is just writing, right?). How would one reopen it for reading?
I got the following (which works):
FILE *tmpFile = tmpfile();
/* write into tmpFile */
...
/* is this correct? */
rewind (tmpFile);
while (fgets (line, MAXSIZE, tmpFile) {
/* put content of tmpFile into another file /*
...
}
Does rewind change the mode? Or why am I able to read from the tmpFile
this way? (I've seen in other posts that other people use rewind as
well this way).
Thanks, Oliver