[C++] 有关时间的操作方法


显示时间

#include <time.h>
#include 
<stdio.h>

main()
{
    
struct tm *tm_ptr;
    time_t the_time;
    (
void) time(&the_time);

    tm_ptr 
= localtime(&the_time);

    printf(
"Raw time is %ldn", the_time);
    printf(
"MyTime show:n");
    printf(
"Date:%02d/%02d/%02d"
           tm_ptr
->tm_year,
           tm_ptr
->tm_mon+1,
           tm_ptr
->tm_mday);

    exit(
0);
}


posted on 2006-04-26 15:30  徐中  阅读(500)  评论(1编辑  收藏  举报

导航