ftell()
函数的语法:函数
long int ftell(FILE *stream)
示例:spa
建立一个源文件:ftell-file.c,其代码以下所示 -指针
#include <stdio.h> void main() { FILE *fp; int length; fp = fopen("file.txt", "r"); fseek(fp, 0, SEEK_END); length = ftell(fp); fclose(fp); printf("Size of file: %d bytes", length); }
这里file.txt的格式以下:code
0x12,0x32
输出结果:blog
Size of file: 11 bytestoken
文件内容以下时,io
0x12,0x32,3
输出结果以下:function
Size of file: 13 bytesclass
这个输出结果很回味无穷,有空能够好好思考一下。stream