• 2021-04-14
    以下程序希望把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。出错的原因是#include int main(){ FILE *fout; char ch; fout=fopen(abc.txt,w); if (fout == NULL) { printf(cannot open infile.
    ); exit(0); } ch=fgetc(stdin); while(ch!=#) { fputc(ch,fout); ch=fgetc(stdin); } fclose(fout); return 0;}
  • 举一反三