c语复制文件
//============================================================================// Name : HelloWorld.cpp// Author : liuqing// Version :// Copyright : Your copyright notice// Description : C语言操作文件//复制文件//============================================================================#include <iostream>#include <stdio.h>#include <stdlib.h>#include <dirent.h>using namespace std;int main() {//定义文件指针FILE *fp,*toFp;//定义输出字符cout << "Reading file...." << endl;//打开文件if ( ((fp = fopen("f:\\aa.txt","rb")) == NULL)){cout << "error open file f:\\aa.txt";}else{if ( (toFp = fopen("F:\\bbmus\\usb.txt","ba+")) == NULL ){cout << "Write error" << endl;}while (!feof(fp)){cout << "reading file!";char ch = fgetc(fp);if (ch != EOF){ fputc(ch,toFp);}}}fclose(fp);fclose(toFp);//关闭文件return 0;}
?