Standard Library Functions in C

adplus-dvertising
fgetpos() Function
Previous Home Next

Description

The C library function,The fgetpos() function stores the current value of the file position indicator in the object pointed to by position. The object pointed to by position must be of type fpos_t.The value stored there is useful only in a subsequent call to fsetpos( ).

Declaration

Following is the declaration for fgetpos() function.

int fgetpos(FILE *stream, fpos_t *pos);

Parameters

stream - The stream pointed to by stream in the object pointed to by pos.

pos - The current position of stream to be stored.

Return Value

The fgetpos function returns successful completion, fgetpos() will return 0; otherwise, it will return a non-zero value and set errno to indicate the error.

Example

#include <stdio.h>

int main()
{
	FILE * s= fopen("fgetposeg.txt","r");
	int a;
	fpos_t pos;
	a = fgetc (s);
	printf ("First character in the file is %c\n",a);
	fgetpos (s,&pos);
	fclose (s);
	return 0;
}

Output

First character in the file is j
Previous Home Next