我想问一下,C语言用fopen()编写打开文件后,是怎么样的,比如说怎么显示文件内容
#include <stdio.h>
int main()
{
FILE *file = fopen("test.txt", "r");
if (!file) {
printf("failed to open file\n");
return -1;
}
char ch;
while ((ch = fgetc(file)) != EOF)
fputc(ch, stdout);
return 0;
}
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
FILE *fp = fopen("t.txt", "rb");
char c ;
while(c!=EOF)
{
char c = fgetc (fp);
printf("%c",c);
}
printf("");
return 0;
}