1 //ftell函数的作用是返回文件位置指针的位置,给出当前位置指针相对于文件头的字节数 2 //返回值为long,当函数调用出错时,函数返回-1L 3 //ftell(文件指针) 4 #include<stdio.h> 5 #include<stdlib.h> 6 int main(){ 7 FILE *fp; 8 long i; 9 if((fp=fopen("file_data.txt","r"))==NULL){ 10 printf("打开文件失败\n"); 11 exit(0); 12 } 13 fseek(fp,0L,SEEK_END); 14 i=ftell(fp); 15 fclose(fp); 16 printf("文件的字节数为:%ld\n",i); 17 return 0; 18 }
C语言学习(42)
猜你喜欢
转载自www.cnblogs.com/Tobi/p/9239938.html
今日推荐
周排行