fgetpos() - I/O Function
How is "fgetpos()" used in C++?
How to get current file position?
is an I/O function which is used to get the current value of the file position indicator in the object pointed by the position. The function return a zero value on success, a non-zero value if an error occurs.
int fgetpos( FILE * stream, fpos_t *position );
int main ()
FILE * str= fopen ("fgetposeg.txt","r");
a = fgetc (str);
printf ("First character in the file is %c\n",a);
First character in the file is j
In the above example the "fgetpos()" is used to find the first character from the text file. This gives the current file position.