程序开始打印程序信息
void printSoftwareInfo(const char *programName, const char *date, const char *time)
{
char s_month[5];
int month, day, year;
static const char month_names[] = "---JanFebMarAprMayJunJulAugSepOctNovDec";
sscanf(date, "%s %d %d", s_month, &day, &year);
month = (strstr(month_names, s_month) - month_names) / 3;
cout << "software name: " << programName << endl;
cout << "compiling time: "
<< year << "-"
<< month << "-"
<< day << " "
<< time
<< endl;
}
调用:
int main(int argc, char **argv)
{
int ret = RET_ERROR;
printSoftwareInfo(argv[0], __DATE__, __TIME__);
return 0;
}