文件写入成了死循环······求帮助·····
程序代码:
#include<stdio.h> #include<stdlib.h> void main() { FILE *fp; char ch,filename[10]; scanf("%s",filename); if((fp=fopen(filename,"w"))==NULL) { printf("Error\n"); exit(0); } ch=getchar(); ch=getchar( ); while(ch!='1') { fputc(ch,fp); putchar(ch); } putchar(10); fclose(fp); }
写出来就是无限个输入的第一个字符···求解释····