FILE *fp; char ch; fp=fopen("C:\\Documents and Settings\\Administrator\\桌面\\love_note.txt","w+"); if(fp == NULL) { printf("Cannot open file strike any key exit!"); exit(1); } while(1) { scanf("%c",&ch); if(ch =='#') break; fprintf(fp,"%c",ch); } fclose(fp); }
温馨提示:答案为网友推荐,仅供参考