//定义一个取 时间的函数,返回string类型。
string time()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
time (&rawtime);
timeinfo = localtime (&rawtime);
strftime (buffer,80," %F-%T",timeinfo);//将时间转换成字符串。
// puts (buffer);
//cout << buffer <<endl;
return buffer;
}
//写入文件
ofstream log ("./log.txt",ios::ate|ios::app);if (log.is_open())
log << "--->>> "<<time()<< endl;
log.close();