注册 登录
编程论坛 C++教室

C++怎样获取系统时间

飞天小丰 发布于 2010-09-07 20:08, 742 次点击
各位高手,问一下
在c++中怎样获取当前的系统时间 且时间格式为:日/月/年
谢谢了!
5 回复
#2
ciweitou1632010-09-07 21:44
#3
ToBeOOP2010-09-07 23:29
可以使用GeTCurrentTime函数...
#4
蛤蟆VS天鹅2010-09-08 21:14
#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;
}
#5
我真是木小板2010-09-09 15:20
这个东西有意思`
#6
x_wangyue2010-09-09 16:00
使用系统函数:sysytem
#include<stdlib.h>
#include<iostream>
using namespace std;
void main()
{
     system("time");
}
1