Does fgets () move the file pointer?

Does the fgets () function automatically move the file pointer to the position before the parameter value I specified?

eg:

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

Couldn't find this in any book. Hence the request.

+3


source to share


2 answers


after using fgets (a, 5, fp1) the file pointer moves forward 5 positions?



The pointer fp1

does not affect the call fgets

(or any other I / O procedure stdio

); The object FILE

that is pointing fp1

will be updated to reflect the new file position, but the pointer itself does not change.

+1


source


The file pointer is not changed by the function fgets

.



However, the file offset increases by the number of bytes actually read.

+3


source







All Articles