Hi,
how can i read first line two times without close file?
Can we please know the intention behind this question?
read the first line
rewind the pointer to 0
read the first line again
rewind the pointer to 0
Or: read first line and copy to a second char*
i have to read the first line and after the file completely
Let's assume you have a file like this:
- This is line 1
- Line 2
- And finally line 3
Do you want to have a result like:
- This is line 1
- This is line 1
or:
- This is line 1
- Line 2
- And finally line 3
- This is line 1
or something completely else?
i have a function that reads the first line and another function that must read all lines. i don't want open the file two times so i pass the file pointer to the second function which starts to read from the second line.
fopen -> fgets -> fseek -> fgets until eof -> fclose
thanks
Another way would be to fopen the file record the offset with fgetpos and read a line and reset the offset to the beginning with fsetpos and finally read the entire file...
fopen / fgetpos / fgets / fsetpos / read entire file