hey, about file pointers

Hello! the question is in C! (sorry for that) :

Is it possible to run with two pointers on the same file having each of them point to different location..?

Lets say:

FILE* F = fopen("new.txt","r");
char c = fgetc(F); // moving the ptr to the next char in file.
FILE* F2 = F;
char c = fgetc(F); // moving the ptr one more step forward


Doing that make F2 change too.
Question is: is it possible to make one pointer to a file STOP while the other keep running?

thanks a lot!
Last edited on
It's the same in C and in C++: there is only one file I/O position indicator associated with each open file. If you need to read from two different positions in the same file, either seek to the position before reading (see the functions ftell()/fseek(), fgetpos()/fsetpos() in C), or open the file twice.
Topic archived. No new replies allowed.