Definition | #include <stdio.h> long ftell(FILE *fp);
To process files > 2 GB, proceed as follows:
There is no functional difference between | |
Return val. | Position in the file if successful: | |
for binary files, the number of bytes that offsets the read/write pointer from the beginning of the file, for text files, the absolute position of the read/write pointer. | ||
-1 | if an error occurs. | |
Notes | The functions
| |
Example | In the following program, each character in file is output with the position of the read/write pointer, starting with the eleventh character (only functions with binary files). #include <stdio.h> int main(void) { FILE *fp; int c; if((fp = fopen("file","rb")) != NULL) { /* the first 10 characters are skipped */ fseek(fp,10L,SEEK_SET); while((c=getc(fp)) != EOF) printf("Position : %ld, character : %c\n",ftell(fp),c); fclose(fp); } return 0; } | |
See also | fseek, fseek64, fgetpos, fgetpos64, ftell, ftell64, tell |