返回狼盟编程首页
编程搜索 [狼盟旧档]
论坛统计


请输入搜索关键字:
├─◆ 狼盟首页 > 查看贴子 > 详细信息

楼主

请教一个显示及设置时间日期的问题(急!MM在线等~)


各位高手谁能帮我写下面的小程序!明天就要交!我学VC刚三天……



编写一个DATETIME类的完整程序,能够显示及设置计算机内的时间日期,要用到库文件TIME.H中的时间日期函数。



不甚感激!!!







bitxy [ 1 楼 ]
2004-11-30 22:39:00
有人愿意帮我吗? 

wishing23 [ 2 楼 ]
2004-12-01 11:15:00
#include <stdio.h>
#include <time.h>
void main( void )
{
/*
struct tm {
        int tm_sec;     // seconds after the minute - [0,59]
        int tm_min;     /* minutes after the hour - [0,59]
        int tm_hour;    /* hours since midnight - [0,23]
        int tm_mday;    /* day of the month - [1,31]
        int tm_mon;     /* months since January - [0,11]
        int tm_year;    /* years since 1900
        int tm_wday;    /* days since Sunday - [0,6]
        int tm_yday;    /* days since January 1 - [0,365]
        int tm_isdst;   /* daylight savings time flag
        };
*/
    tm    systime;
    _getsystime(&systime);
    printf( "Current OS date and time: %s", asctime( &systime ) );

    tm    timetobeset;
    // below is the value to be set for the system time ( I set it to 2004/12/01 0:00:00 ) :
    timetobeset.tm_sec    =    0;        // seconds after the minute - [0,59]
    timetobeset.tm_min    =    0;        // minutes after the hour - [0,59]
    timetobeset.tm_hour    =    0;        // hours since midnight - [0,23]
    timetobeset.tm_mday    =    1;        // day of the month - [1,31]
    timetobeset.tm_mon    =    11;        // months since January - [0,11]
    timetobeset.tm_year    =    104;    // years since 1900
    timetobeset.tm_wday    =    3;        // days since Sunday - [0,6]
    timetobeset.tm_yday    =    335;    // days since January 1 - [0,365]
    timetobeset.tm_isdst=    0;        // daylight savings time flag
//    _setsystime(&timetobeset, 0);
    printf( "Current OS date and time is set to be : %s", asctime( &timetobeset ) );


东方一杰 [ 3 楼 ]
2004-12-02 23:11:00
我觉着你只要在控制面板中设置不就行了啊,我不懂啊,你怎么还问这啊,这都是基本的操作知识啊,不知道你还有什么意思啊! 

东方一杰 [ 4 楼 ]
2004-12-02 23:12:00
哦,你说的是程序啊,是我错了啊,不好意思! 

bitxy [ 5 楼 ]
2004-12-03 21:33:00
多谢~~!
要是用类实现就更好了!