Search code examples
cfilepointersfgets

Does fgets() move the file pointer?


Does the fgets() function move the file pointer automatically to the position till the parameter of the size mentioned by me?

for example:

the content of the file p.txt is " I am a good boy ". After using fgets(a, 5, fp1) does the file pointer move 5 positions ahead?


Solution

  • after using fgets(a,5,fp1) does the file pointer move 5 positions ahead ?

    The pointer fp1 is not affected by the fgets call (or any other stdio I/O routine); The FILE object that fp1 points to will be updated to reflect the new file position, but the pointer itself does not change.