C fgetpos function gets the file pointer position.
Syntax
C fgetpos function has the following format.
int fgetpos(FILE *stream, fpos_t *position);
Header
C fgetpos function is
from header file stdio.h
.
Description
C fgetpos function stores the current file position indicator.
C fgetpos function returns zero on success or nonzero on failure.
'fpos_t *position' is useful only in a call to fsetpos().
Example
Use C fgetpos function to get the file pointer position.
#include <stdio.h>
#include <stdlib.h>
//w ww. j a v a 2 s. co m
int main(int argc, char *argv[])
{
FILE *fp;
fpos_t file_loc;
if((fp=fopen("test","r"))==NULL) {
printf("Cannot open file.\n");
exit(1);
}
fgetpos(fp, &file_loc);
fclose(fp);
}