#include <stdio. h> void maino i fiLE fp 例:从键盘输入字 char ch *filename="out. txt 符,逐个存到磁盘if( p=fopen( filename,"w")=NULL 文件中,直到输入{ printf(" cannot open file\n”) “#“为止 exit(O) printf( Please input string: ) ch=getchar(; while(ch!=#) i fputc(ch, fp); putchar(ch ch=getchar(; fclose(fp);例: 从键盘输入字 符,逐个存到磁盘 文件中,直到输入 ‘#“为止 #include <stdio.h> void main() { FILE *fp; char ch,*filename="out.txt"; if((fp=fopen(filename,"w"))==NULL) { printf("cannot open file\n"); exit(0); } printf("Please input string:"); ch=getchar(); while(ch!='#') { fputc(ch,fp); putchar(ch); ch=getchar(); } fclose(fp); }