[C++] 纯文本查看 复制代码
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#define PHP_EOL "\n"
using namespace std;
bool file_put_contents(string fileName , string fileContents)
{
ofstream file;
file.open(fileName, ios::out);
// 若文件打开失败
if (!file.is_open())
{
return false;
}
file << fileContents << endl;
file.close();
return true;
}
}
int main()
{
file_put_contents("嘤嘤嘤.txt", "嘤嘤嘤" PHP_EOL "嘤嘤嘤2");
system("pause");
return 0;
}