写字符并验证
#include <stdio.h> #include <stdlib.h> #define MAXN 300 int main(void){ FILE *fp; char ch; char string[MAXN]; gets(string); if ((fp=fopen("f3.txt", "w+")) == NULL) { printf("File open errpr! "); exit(0); } fputs(string, fp); rewind(fp); while ((ch=fgetc(fp))!=EOF) { putchar(ch); } if ((fclose(fp))) { printf("Can not close the file! "); exit(0); } return 0; }