hmj*_*mjd 12
O_APPEND打开文件时包含标志.请参阅参考页面_open().
因为这是C++考虑使用ofstream而不是.这些是类型安全的,并且不需要指定写入文件的参数的长度:
std::ofstream out(full_path, std::ios_base::app);
if (out.is_open())
{
out << "----Session----\n\n"
<< "Date/Time: " << datetime << "\n\n"
<< "Text: " << text << "\n\n\n\n";
}
Run Code Online (Sandbox Code Playgroud)