c语言一行一行的读写文件

读 :
 
  
#define MAXLINElen 10000
#define bufLINElen 1024

void readline()
{
FILE *fp;
 char arr[bufLINElen +1];

 if ((fp = fopen ("test.txt", "r")) == NULL)
 {
  perror ("File open error!\n");
  exit (1);
 }
 while ((fgets (arr, MAXLINE, fp)) != NULL)
 {
  fputs (arr, stdout);
 }
}
写:
fputs(const char *s, FILE *fp); 一次一个字符串的写
s+"\n"  表示一行结束!

你可能感兴趣的:(笔记(小知识))