程序分析题(写出当输入字符串123456789后程序的运行结果) #include
main( ) { FILE *fp;char ch; if((fp=fopen("string","w"))==NULL) { printf("Cannot open file,press any key exit!"); getch( ); exit(1); } printf("input a string:\n"); ch=getchar( ); while (ch!='\n') { fputc(ch,fp); ch=getchar( ); } fclose(fp);fp=fopen ("string","r"); ch=fgetc(fp); while(ch!=EOF)/* 写入成功则返回写入的字符, 否则返回一个EOF。 */ { putchar(ch); ch=fgetc(fp); } printf("\n"); fclose(fp); }