C中怎样调用系统时间
比如现在时间:早上:08:07:06
下午:15:15:15
晚上:21:21:21
程序代码:#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;
}
