|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
按照小甲鱼的课堂敲的代码,但为什么读取hello.txt文件后显示的是框框
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- FILE *fp;
- int ch;
- if ((fp = fopen("hello.txt", "r")) == NULL){
- printf("打开文件失败。\n");
- exit(EXIT_FAILURE);
- }
-
- while (ch = getc(fp) != EOF){//EOF == end of fail(整形值)
- putchar(ch);
- }
- fclose(fp);
-
-
- return 0;
- }
复制代码
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- FILE *fp;
- int ch;
- if ((fp = fopen("hello.txt", "r")) == NULL){
- printf("打开文件失败。\n");
- exit(EXIT_FAILURE);
- }
-
- while ((ch = getc(fp)) != EOF){//EOF == end of fail(整形值)
- putchar(ch);
- }
- fclose(fp);
-
-
- return 0;
- }
复制代码
|
-
hello.txt中的文本内容
-
程序打印出来的结果
|