C++怎么读取txt文件中的学生信息,

2024-11-25 19:21:01
推荐回答(1个)
回答1:

#include
main()
{
FILE *fp;
char ch;
if((fp=fopen("e10_1.c","rt"))==NULL)//读入文件e10-1.c
{
printf("Cannot open file strike any key exit!");
getch();
exit(1);
}
ch=fgetc(fp);
while (ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}