0
我有以下代码:
int main()
{
time_t rawtime;
time (&rawtime);
printf ("The current local time is: %s", ctime (&rawtime));
std::string datetoString(ctime (&rawtime));
return 0;
}
std::string datetoString (char dat[])
//how to add ctime(&rawtime) in char dat[]?
{
std::string rez;
struct tm;
strptime(dat, "%d %b %Y %H:%M:%S", &tm);
// what library do i have to inclide for strptime?
rez=tm.tm_mday + "-" + tm.tm_mon +"-"+ tm.tm_year+ hour+min+sec;
//how to print the hour,minutes and secods?
return rez;
}
我已经在我发表过评论我的问题的地方的错误。
你有这个代码,和...? – Pih 2011-05-26 08:59:10
我有错误在dat [] – marryy 2011-05-26 09:03:05
这是家庭作业 – Blazes 2011-05-26 09:04:55