正在加载图片...
例1:从键盘输入字符, include <stdio. h> 逐个存到磁盘文件中, maino FILE*fp 直到输入‘#“为止,在 char ch, filename=out. txt 显示器上同时显示出来。i(p= - fopen(filename, WD==NULL i printf("cannot open filen") 运行情况: exit(O) computer and c#输入 computer and c输出 printf("Please input string ch=getchar while(ch!=# i fputc(ch, tp) putchar(ch) ch=getchar( fclose(fp)例1:从键盘输入字符, 逐个存到磁盘文件中, 直到输入‘#“为止,在 显示器上同时显示出来。 运行情况: computer and c# 输入 copmputer and c 输出 #include <stdio.h> 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); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有