读取文件并输出到屏幕
程序代码:
#include <stdio.h> #include <stdlib.h> int main(void) { FILE *fp; char ch, filename[10]; scanf("%s", filename); if ((fp = fopen(filename, "w")) == NULL) { printf("cannot open file\n"); exit(0); } while (getchar() != '\n'); //清空缓冲区 ch = getchar(); while (ch != '#') { fputc(ch, fp); ch = getchar(); } putchar('\n'); fclose(fp); if ((fp = fopen(filename, "r")) == NULL) { printf("cannot open file\n"); exit(0); } while (!feof(fp)) { ch = fgetc(fp); putchar(ch); } system("pause"); return 0; }
我的问题:
为什么最后输出时“rongyao”和"请按任意键继续..."之间会有一段间距,这段间距是什么内容?