c语言中fgetc函数:显示文件内容
时间:2021-06-11 18:30:11
收藏:0
阅读:0
1、显示a.txt文件的内容
#include <stdio.h> int main(void) { FILE *fp; int ch; char filename[FILENAME_MAX]; printf("Please input the filename: "); scanf("%s", filename); if((fp = fopen(filename, "r")) == NULL) printf("\aFile oprn failed.\n"); else { while((ch = fgetc(fp)) != EOF) putchar(ch); fclose(fp); } return 0; }
评论(0)