xkdn
//搂行读取TXT 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LINE 1024
int main()
{
     char buf[MAX_LINE];  /*缓冲区*/
     FILE *fp;            /*文件指针*/
     int len;             /*行字符个数*/
     if((fp = fopen("test.txt","r")) == NULL)
     {
         perror("fail to read");
         exit (1) ;
     }
     while(fgets(buf,MAX_LINE,fp) != NULL)
     {
         len = strlen(buf);
         buf[len-1] = \'\0\';  /*去掉换行符*/
         printf("%s %d \n",buf,len - 1);
     }
      return 0;
}

 

分类:

技术点:

相关文章:

  • 2022-02-13
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
猜你喜欢
  • 2021-09-16
  • 2022-12-23
  • 2021-11-11
  • 2021-04-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
相关资源
相似解决方案