【发布时间】:2014-04-14 15:09:52
【问题描述】:
我想制作一个考勤系统,它将系统日期和时间作为文件的文件名,例如: 平时是这样的
int main () {
time_t t = time(0); // get time now
struct tm * now = localtime( & t );
cout << (now->tm_year + 1900) << '-'
<< (now->tm_mon + 1) << '-'
<< now->tm_mday
<< endl;
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
但我想用系统日期和时间代替 example.txt 我已经通过在程序中包含 ctime 头文件来计算时间,上面的程序只是示例。
【问题讨论】:
-
那么...你的问题是什么?