main( FILE *fp; char string811 例 if((fp=fopen("file. txt","W==NULL) 从键盘读入字 i printf("cann't open file"); exit(0);) 符串存入文件, if(strlen(gets(string))>0) 再从文件读回 显示 i fputs(string, fp) puts("n", fp); fclose(fp); if((fp=fopen(file. txt","r -=NULL) i printf(" cann't open file);exit(0);) if(fgets(string, 81, fp)=NULL) puts(string); fclose(fp)例: 从键盘读入字 符串存入文件, 再从文件读回 显示 main() { FILE *fp; char string[81]; if((fp=fopen("file.txt","w"))==NULL) { printf("cann't open file");exit(0); } if(strlen(gets(string))>0) { fputs(string,fp); fputs("\n",fp); } fclose(fp); if((fp=fopen("file.txt","r"))==NULL) { printf("cann't open file");exit(0); } if(fgets(string,81,fp)!=NULL) puts(string); fclose(fp); }