C言語インスタンス-ファイルから1行を読み込む
2077 ワード
C -
。
runoob.txt :
$ cat runoob.txt
runoob.com
google.com
#include
#include // exit()
int main()
{
char c[1000];
FILE *fptr;
if ((fptr = fopen("runoob.txt", "r")) == NULL)
{
printf("Error! opening file");
// NULL
exit(1);
}
// ,
fscanf(fptr,"%[^
]", c);
printf(" :
%s", c);
fclose(fptr);
return 0;
}
:
:
runoob.com
転載先:https://www.cnblogs.com/bytebee/p/8535688.html