Function name : ftell
Header file : <stdio.h>
Function prototype : long ftell(FILE *stream);
Function : The offset is the number of bytes from the beginning of the file.
Parameters : FILE *stream file stream that needs to return a pointer
Return value : Returns the position of the current file pointer successfully, returns -1L on error, which is the -1 value of a long integer.
Program example : Open the file, input the string into the file stream, and output the length of the file
#include<stdio.h>intmain(void){FILE*stream=fopen(test.txt,w+);if(!stream){printf(cannotopenthefilen);return0;}fprintf(stream,www.dotcpp.com );printf(Thefilepointerisatbyte%ldn,ftell(stream));fclose(stream);return0;}
Running results
Thefilepointerisatbyte14