ftell
raw OCR
Returns the current file pointer.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
long int ftelKFILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
ftell returns the current file pointer for stream. The offset is measured in bytes from the beginning of the file (if the file is binary).
The value returned by ftell can be used in a subsequent call to fseek.
Return value
ftell returns the current file pointer position on success. It returns -IL on error and sets the global variable errno to a positive value.
See also
Example
#include <stdio.h>
int main(void)
{
FILE *stream;
stream = fopen( "MYFILE.TXT", "w+");
fprintf (stream, "This is a test");
printf("The file pointer is at byte %ld\n", ftell(stream)
fclose(stream) ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/ftell/
· short form /3.1/ftell/