dede 管理多个网站,app网站建设宣传方案,辽宁网站推广的目的,外包网站该怎么做帐ftell函数用于得到文件位置指针当前位置相对于文件首的偏移字节数#xff0c;在随机方式存储文件时#xff0c;由于文件位置频繁的前后移动#xff0c;程序不容易确定文件的当前位置。 /***
a.txt
***/
asd
gsdert
dfhjtew /***
ftell.c
***/
#includestdio.hint ma… ftell函数用于得到文件位置指针当前位置相对于文件首的偏移字节数在随机方式存储文件时由于文件位置频繁的前后移动程序不容易确定文件的当前位置。 /***
a.txt
***/
asd
gsdert
dfhjtew /***
ftell.c
***/
#includestdio.hint main()
{FILE *p fopen(./a.txt,rb);fseek(p,2,SEEK_SET);char buf[100] {0};fgets(buf,sizeof(buf),p);printf(buf %s,buf);printf(ftell %ld\n,ftell(p));fclose(p);return 0;
} 运行结果 ubuntu1604ubuntu:~/wangqinghe/C/20190727$ ./ftell buf d ftell 4 /***
ftell.c
***/
#includestdio.hint main()
{FILE *p fopen(./a.txt,rb);fseek(p,2,SEEK_SET);char buf[100] {0};fgets(buf,sizeof(buf),p);printf(buf %s,buf);fgets(buf,sizeof(buf),p);printf(buf %s,buf);printf(ftell %ld\n,ftell(p));fclose(p);return 0;
} 运行结果 ubuntu1604ubuntu:~/wangqinghe/C/20190727$ ./ftell buf d buf gsdert ftell 11 转载于:https://www.cnblogs.com/wanghao-boke/p/11260665.html