程序代码:
#include <stdio.h>
int main()
{
FILE *fp;
char ch,filename[50];
printf("请输入要打开的文件名:");
scanf("%s",filename);
if((fp=fopen(filename,"r"))==NULL)
{
printf("不能打开文件:");
return;
}
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
fclose(fp);
}