起源
代码中文件写入失败,测试接口
参考博客
测试代码
//main.cpp
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
cout << "Main start running.." << endl;
ofstream imageOut;
string path = "./run.log";
imageOut.open(path, ios::out | ios::binary);
if (!imageOut.is_open())
{
cout << "Save image data to file failed, because open file failed." << endl;
return -1;
}
imageOut.write("hello world!",14);
imageOut.close();
return 0;
}
编译
g++ main.cpp -o main -std=c++11