首页 > 解决方案 > Ofstream does not write in file

问题描述

I have problem with ofstream. I have program, whitch must write in file info (langulange settings). If i start with VS 2019 Debug or Release all is OK, but whith installer ofstream does not want to work. After installing program read from file, but dont want to write. Can you help?

int langulange = 1;
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char* argv[]) {
    ifstream file("config.txt");
if (!file.is_open()) {
    ofstream out("config.txt");
    out << langulange;
    out.close();
    return 0;
}
}

标签: c++filefstreamofstream

解决方案


推荐阅读