C中怎样调用系统时间
比如现在时间:早上:08:07:06
下午:15:15:15
晚上:21:21:21
2010-08-17 11:19
2010-08-17 11:54
2010-08-17 12:52
程序代码:#include <ctime>
#include <iostream>
using namespace std;
int main()
{
char * timeTemp;
time_t theTime;
time( &theTime ); // get the calendar time
tm *t = localtime( &theTime ); // convert to local
cout << "The time is: " << asctime(t);
strncpy(timeTemp,(asctime(t))+11,8); //只获取时间部分
cout<<timeTemp<<endl;
return 0;
}

2010-08-17 13:05
2010-08-18 01:06
2010-08-19 09:05