Borland C++ reference

fgetpos

raw OCR

Gets the current file pointer.

Defined in header <stdio.h>

Syntax

#include <stdio.h>
int fgetpos(FILE *stream, fpos_t *pos);

Portability

DOSUNIXWindowsANSI CC++ only
■■■

Remarks

fgetpos stores the position of the file pointer associated with the given stream in the location pointed to by pos. The exact value is a magic cookie; in other words, it is irrelevant to your purposes.

The type fposj is defined in stdio.h as typedef long fpos_t;.

Return value

On success, fgetpos returns 0. On failure, it returns a nonzero value and sets the global variable errno to EBADF or EINVAL.

See also

Example

#include <string.h>
#include <stdio.h>
int main(void)

   FILE *stream;
   char string [] = "This is a test";
   fpos_t filepos;

   /* open a file for update  */
   stream = fopen( "DUMMY.FIL", "w+");
   /* write a string into  the file */
   fwrite (string, strlen(string), 1, stream);

   /* report the file pointer  position */
   fgetpos (stream, ftfilepos);
   printf("The file pointer  is at byte %ld\n", filepos);
   fclose(stream) ;

   return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.