69,382
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ()
{
char c[1024] = { };
FILE *fp = NULL;
fp = fopen ("file.txt", "r");
printf ("-------print the file ------\n");
while (fgets (c, sizeof (c), fp) != NULL)
{
printf ("%s", c);
}
printf ("\n------------------------------\n");
fclose(fp);
return 0;
}
比较简单的代码,*.exe和file.txt要在同一目录。