📄 program_5_3.cpp
字号:
// Program 5.3.1: File io example
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main() {
ifstream sin("d:\\temp\\in1.txt");
if (!sin) {
cerr << "Cannot open in1.txt" << endl;
exit(1);
}
ofstream sout("out1.txt");
string s;
while (sin >> s) {
sout << s << endl;
}
sin.close();
sout.close();
sin.open("in2.txt");
if (!sin) {
cerr << "Cannot open in2.txt" << endl;
exit(1);
}
sout.open("out2.txt", (ios_base::out | ios_base::app));
while (sin >> s) {
sout << s << endl;
}
sin.close();
sout.close();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -