标签:
#include "stdafx.h" #include <stdio.h> #include <stdlib.h> int main() { FILE *readfile,*writefile; char ch; fopen_s(&readfile,"ReadMe.txt","r"); fopen_s(&writefile,"abc.txt","w"); if(readfile == NULL) { printf_s("读文件打开失败"); getchar(); exit(1); } if(writefile == NULL) { printf_s("文件打开失败"); getchar(); exit(1); } while((ch = fgetc(readfile)) != EOF) { printf_s("get a word"); fputc(ch,writefile); } int id1 = fclose(readfile); int id2 = fclose(writefile); system("pause"); if(id1 != 0) { printf_s("文件关闭失败"); } else { printf_s("文件关闭成功"); } if(id2 != 0) { printf_s("文件关闭失败"); } else { printf_s("文件关闭成功"); } system("pause"); return 0; }
ReadMe.txt 与 abc.txt stdafx.cpp stdafx.h 放在一起
标签:
原文地址:http://www.cnblogs.com/joyclub/p/4434893.html