大神求解啊,红色的语句没有时运行正常,但是一旦加进去就输出屯字一大堆
#include<stdio.h>main()
{
void openfile();
FILE *fp;
char ch,bh;
char *file="c:\\book\\book.txt";
if(!(fp=fopen(file,"r+")))
{
printf("open %s is failed",file);
exit(0);
}
openfile(fp);
printf("please input a string:");
bh=getchar();
while(bh!='\n')
{
fputc(bh,fp);
bh=getchar();
}
printf("\n");
openfile(fp);
fclose(fp);
}
void openfile(fp)
{
char ch;
ch=fgetc(fp);
while(ch!=EOF)
{
putchar(ch);
ch=fgetc(fp);
}
printf("\n");
}