struct tm *TimeBegin=NULL;   
    TimeBegin->tm_year=2005;
    TimeBegin->tm_mon=1;
    TimeBegin->tm_mday=1;
    TimeBegin->tm_hour=0;
    TimeBegin->tm_min=0;
    TimeBegin->tm_sec=0;
我这么直接赋值不行,出错,请问应该怎么赋值呢,谢谢

解决方案 »

  1.   

    // crt_mktime.c
    /* The example takes a number of days
     * as input and returns the time, the current
     * date, and the specified number of days.
     */#include <time.h>
    #include <stdio.h>int main( void )
    {
       struct tm when;
       __time64_t now, result;
       int    days;   _time64( &now );
       when = *_localtime64( &now );
       printf( "Current time is %s\n", asctime( &when ) );
       days = 20;
       when.tm_mday = when.tm_mday + days;
       if( (result = _mktime64( &when )) != (time_t)-1 )
          printf( "In %d days the time will be %s\n", 
                  days, asctime( &when ) );
       else
          perror( "_mktime64 failed" );
    }
      

  2.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_mktime.asp
      

  3.   

    struct tm *TimeBegin=new tm ;