What is the meaning of ftell function in C language
This article introduces the relevant knowledge of "what is the meaning of ftell function in c language". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. C language function ftell is used to obtain the offset bytes of the current position of the file position pointer relative to the beginning of the file.
2. Get the size of the current file through the ftell function, and then read the buffer through the fread function.
Returns the current value of the location identifier if successful or-1L if an error occurs.
examples
#include #include //fseek function calls int main(){ long position; char list[100]; /* rb+ Read/Write Opens a binary file, allowing data to be read. */ FILE * fp = fopen("a.txt", "rb+"); if (fp == NULL) { printf("file error\n"); exit(1); } fread(list,sizeof(char),100,stream); //get position after read position=ftell(stream); printf("Position after trying to read 100 bytes:%ld\n",position); fclose(stream); stream=NULL; return 0;}"What does the ftell function mean in C language" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!