文件无法写入
来源:8-11 文本文件的操作
 
			慕尼黑8261772
2020-08-20
#include <iostream>
#include <limits>
#include <fstream>
using namespace std;
int main() {
    int a;
    int index = 0;
    fstream fout;
    fout.open("testBuffer.txt", ios::app);
    if (!fout){
        cerr<<"the file open error"<<endl;
    }else {
        while (cin >> a) {
            fout << a << endl;
            index++;
            if (index == 5) {
                break;
            }
        }
        cin.ignore(numeric_limits<std::streamsize>::max(), '\n');
        char ch;
        cin >> ch;
        fout << "the last char is: " << ch << endl;
        fout.close();
        return 0;
    }
}

写回答
	1回答
- 
				  quickzhao 2020-08-20 请确认一下是否有权限,然后具体描述一下什么系统,运行完程序什么现象。 0112022-04-09
相似问题
