|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- #include <fstream>
- using namespace std;
- int main(int arc, char *arv[])
- {
- const char FILENAME[] = "file1.txt";
- ofstream fout;
- fout.open(FILENAME);
- fout << "this is a test file!";
- fout.close();
- //以上是创建了一个文本文件
- /////////////////////////////////////////////////////////////////////
- ifstream fin(FILENAME, ios::binary);//打开源文件
- char ch;//中介
- ofstream fout2("copyfile.txt", ios::binary);//创建目标文件
- while(fin >> ch)//源文件流入ch
- {
- fout2 << ch;//ch流入目标文件
- }
- return 0;
- }
复制代码 以上打开文件方式是以ios::binary格式的,为什么空格符无法转移。
源文件中的"this is a test file!" 到目标文件中变成"thisisatestfile!"
|
|