c语言 如何将文件中的字符串逐行读入保存在字符数组中

如题所述

#include
#include
#include
int
main(void){FILE
*fp
=
NULL;char
buf[1024]
=
{0};char
*p
=
buf;fp
=
fopen("./tt",
"r+");//注:知当前目录下道的版tt文件已存在权if(NULL
==
fp){return
0;}fseek(fp,
0,
SEEK_SET);while(1
==
fscanf(fp,
"%s",
p)){p
=
buf
+
strlen(buf);*p++
=
'$';}printf("%s
",
buf);printf("\n\r");fclose(fp);return
0;}
温馨提示:答案为网友推荐,仅供参考
相似回答