📄 11-4-2-3.cpp
字号:
#include <fstream.h>
#include <stdlib.h>
void main()
{ ifstream sfile("abc.txt");
ofstream dfile("result.txt");
char ch;
if(!sfile)
{ cout<<"不能打开源文件:"<<endl; exit(1); }
if(!dfile)
{ cout<<"不能打开目标文件:"<<endl;exit(1); }
sfile.unsetf(ios::skipws); //关键! 把跳过空白控制位置0,
// 即不跳过空白,否则空白全部未拷贝
while(sfile>>ch)
dfile<<ch;
sfile.close(); //如没有这两个关闭函数,析构函数也可关闭
dfile.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -