当前位置:网站首页>Fgetc() reads content from file

Fgetc() reads content from file

2022-06-26 16:41:00 Muzi..

#include<stdio.h>
#include<stdlib.h>
int  main( )
{
    
	 FILE *fp;
	 char ch,filename[20];
	 printf("please input the filename you want to write:");
	 scanf("%s",filename);
	 if(!(fp=fopen(filename,"r")))
	 {
    
	 	 printf("cannot open the file!\n");
	 	 exit(0);
	 }
	
	 
	  while(ch!=EOF)
	 {
    
	 	 ch=fgetc(fp);
	 	 putchar(ch);
	 }
	 fclose(fp);

	 
}
原网站

版权声明
本文为[Muzi..]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170506478604.html