{
FILE *fp;
char ch,inputfile[256];
printf("请输入文件地址:");
gets(inputfile) ; /*输入文件名 -*/
fp=fopen(inputfile,"r");
/*如果文件不存在*/
if(fp==0){
printf("%s 打开失败",inputfile);
exit(0); //退出程序
}
//文件存在
printf("%s 文件内容如下:",inputfile);
/* while((ch = fgets(fp)) !=EOF){
putchar(ch);
} */
while(!feof(fp))
{
putchar(fgets(*fp));
}
printf("\n");
fclose(fp);
return 0;
}
文件地址有问题,你试试把文件放和debug文件放一个文件夹,然后只写文件名