C语言文件的问题
#include <stdlib.h>#include <stdio.h>
void main()
{FILE *fp;
char ch,filename[10];
scanf("%s",filename);
if((fp=fopen(filename,"w"))==NULL)
{
printf("cannot open file\n");
exit(0);
}
ch=getchar( );
ch=getchar( );
while(ch!='#')
{
fputc(ch,fp);
putchar(ch);
ch=getchar();
}
fclose(fp);
putchar(10);
}
请问为什么要有两个ch=getchar();