# include stdio.h//ftell int main (void ) {FILE *file; 长偏移; file=fopen('tmp.c ',' r ' ); if (! 文件(printf ) '文件打开失败!' ); 返回1; }offset=ftell(file; printf ('当前文件位置为%ldn ),offset ); for(intI=0; i5; I ) fgetc (文件); }offset=ftell(file; printf ('当前文件位置为%ldn ),offset ); 返回0; } 结果显示:
当前文件位置为:0
当前文件位置为:5
ftell的返回值为长整形,long int 可写为 long