正在加载图片...
例从键盘输入字符,逐个# nclude <stdio. h 存到磁盘文件中,直到main 输入‘#“为止{FILE*f char ch, filename=out.txt #include <stdio. h> NULL maint 例读文本文件内容{FLE* 并显示 char ch *filename=out. txt? NULL if(fp=fopen(filename, I==NI i printf("cannot open fileIn") exit(O) while((ch=fgetc(fp))!=EOF) putchar(ch fclose(fp) 判断文本文件是否结束例 #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); } 例 读文本文件内容, 并显示 #include <stdio.h> main() { FILE *fp; char ch,*filename=“out.txt”; if((fp=fopen(filename,”r"))==NULL) { printf("cannot open file\n"); exit(0); } while((ch=fgetc(fp))!=EOF) putchar(ch); fclose(fp); } 从键盘输入字符,逐个 存到磁盘文件中,直到 输入‘#“为止 判断文本文件是否结束
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有