与文件有关
这是一个文件的题,我看不出有毛病,但执行后就是:cannot open this file!我不明白问题在哪怎么就执行不下去?请诸位高手出手.#include"stdio.h"
main()
{
FILE *fp;
char ch,fname[20];
printf("please input file name:\n");
scanf("%s,fname");
if((fp=fopen(fname,"w"))==NULL)
{
printf("cannot open this file!\n");
exit(0);
}
printf("pleas input some text:\n");
ch=getchar();
while(ch!='s');
{
fputc(ch,fp);
ch=getchar();
}
fclose(fp);
printf("\nthe content of the file $s is:\n",fname);
if((fp=fopen(fname,"r"))==NULL)
{
printf("cannot open this file!\n");
exit(0);
}
while(!feof(fp))
{
ch=fgetc(fp);
putchar(ch);
}
fclose(fp);
}