扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:佚名 来源:唯C世界 2007年10月28日
关键字: Linux
#include<stdio.h> main() { FILE *fp; char str[11]; if((fp=fopen("e10_1.c","rt"))==NULL) { printf("Cannot open file strike any key exit!"); getch(); exit(1); } fgets(str,11,fp); printf("%s",str); fclose(fp); } |
#include<stdio.h> main() { FILE *fp; char ch,st[20]; if((fp=fopen("string","at+"))==NULL) { printf("Cannot open file strike any key exit!"); getch(); exit(1); } printf("input a string:\n"); scanf("%s",st); fputs(st,fp); rewind(fp); ch=fgetc(fp); while(ch!=EOF) { putchar(ch); ch=fgetc(fp); } printf("\n"); fclose(fp); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。