[C] 使用ftell函数获取位置指针的位置 →→→→→进入此内容的聊天室

来自 , 2020-07-26, 写在 C, 查看 160 次.
URL http://www.code666.cn/view/8aec5142
  1. /* 使用ftell函数获取位置指针的位置 */
  2. #include <stdio.h>
  3.  
  4. int main(void) {
  5.         FILE * fp = NULL;
  6.  
  7.         fp = fopen("file1.txt", "r");
  8.         if (NULL == fp) {
  9.                 printf("Can't open file \"test.txt\"");
  10.                 return -1;
  11.         }
  12.  
  13.         printf("Before writing:\n");
  14.         printf("ferror(fp) = %d\n", ferror(fp));
  15.  
  16.         fputc('a', fp);
  17.  
  18.         printf("After writing:\n");
  19.         printf("ferror(fp) = %d\n", ferror(fp));
  20.  
  21.         fclose(fp);
  22.         fp = NULL;
  23.  
  24.         return 0;
  25. }
  26.  

回复 "使用ftell函数获取位置指针的位置"

这儿你可以回复上面这条便签

captcha