#include <stdio.h>
int main(){
//FILE 后面必须是指针类型
FILE *fp;
//fopen判断是否正常打开文件,r是只读
if ((fp=fopen("test.txt","r"))!=NULL){
char txt;
//EOF是读到尾部了
while ((txt=fgetc(fp))!=EOF)
printf("%c",txt);
fclose(fp);
}
return 0;
}#include <stdio.h>
int main(){
//FILE 后面必须是指针类型
FILE *fp;
//fopen判断是否正常打开文件,r是只读
if ((fp=fopen("test.txt","r"))!=NULL){
char txt;
//EOF是读到尾部了
while ((txt=fgetc(fp))!=EOF)
printf("%c",txt);
fclose(fp);
}
return 0;
}
被折叠的 条评论
为什么被折叠?