C 读入文件实例

//读入文件实例
#include <stdio.h>
#include <stdlib.h> 
void main()
{
    
    
	FILE *fp;
	char ch;
	if((fp=fopen("1.txt","rt"))==NULL)
	{
    
    
		printf("\nCannot open file strike any key exit!");
		getch();
		exit(1);
	}
	ch=fgetc(fp);
	while(ch!=EOF)
	{
    
    
		putchar(ch);
		ch=fgetc(fp);
	}
	fclose(fp);
} 

猜你喜欢

转载自blog.csdn.net/qq_48167493/article/details/120555666