64,646
社区成员
发帖
与我相关
我的任务
分享
char tmp[15];
double dbl;
ofstream ofs("file.txt");
sprintf_s(tmp, 14, "%.4g ", dbl);
ofs<<tmp;
#include <cstdio>
#include <string>
#include <fstream>
using std::string;
using std::fstream;
int main()
{
string str = "aaaaa\nbbbbb";
ofstream ofs("yourfile");
ofs<<str;
ofs.close();
return 0;
}