fputc的使用
#include "stdafx.h" #include <stdio.h> #include<stdlib.h> int main() { FILE *fp; char ch; char *str = "www.cskaoyan.com"; if(fopen_s(&fp,"ReadMe.txt","at+") != NULL) { printf_s("文件打开失败\n"); getchar(); exit(1); } else { fputs(str,fp); rewind(fp); ch =fgetc(fp); while(ch != EOF) { putchar(ch); ch = fgetc(fp); } printf_s("\n"); int id = fclose(fp); if(id == 0) { printf_s("关闭成功") ; } else printf_s("关闭失败"); } return 0; }