ftell function
Prototype | long int ftell (FILE * Stream); |
Purpose | To get the location of a file pointer. |
Header File | #include <stdio.h> |
Parameters |
Stream | Pointer to an open FILE |
|
Return Value | |
Side Effects |
errno | Set on failure to:
EBADF | Bad file pointer |
ESPIPE | Illegal seek on device |
- These error number constants and the variable errno
are defined in errno.h.
|
|
|
|
Notes |
- File pointer position returned is bytes from the beginning of the file.
|
Example |
#include
#include
. . .
FILE * Account_Master;
long int File_Size;
. . .
if (fseek (Account_Master, 0, SEEK_END) == 0) {
File_Size = ftell (Account_Master);
if (File_Size >= 0)
printf ("File is %i bytes long.", File_Size);
else
printf ("Function ftell failed with error %i.", errno);
} else {
printf ("Seek failed.");
} |
Related functions |
|