⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 program_5_3.cpp

📁 清华关于C++ 的程序讲义 值得一看 关于算法
💻 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 + -