现在的位置: 首页 > 综合 > 正文

Linux – C++ – Print log to file

2013年10月09日 ⁄ 综合 ⁄ 共 263字 ⁄ 字号 评论关闭

Reversion 1: 

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>

int main (int argc, char **argv)
{
    std::stringstream logf_n;
    logf_n << "/tmp/MyApp_" << time(0) << ".log";

    std::ofstream logf(logf_n.str().c_str());
    logf << "Hello World" << std::endl;
    logf.close();

    return 0;
}

抱歉!评论已关闭.