current month in C++

Discussion in 'Programming' started by darkhorn, May 29, 2009.

  1. #1
    How it is printed current month in C++? As an integer.
     
    darkhorn, May 29, 2009 IP
  2. Exorcist

    Exorcist Guest

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    #include <stdio.h>
    #include <time.h>

    void main( )
    {
    char dateStr [9];
    char timeStr [9];
    _strdate( dateStr);
    printf( "The current date is %s \n", dateStr);
    _strtime( timeStr );
    printf( "The current time is %s \n", timeStr);
    }



    or using SYSTEMTIME


    #include <Windows.h>
    #include <stdio.h>

    void main()
    {
    SYSTEMTIME st;
    GetSystemTime(&st);
    printf("Year:%d\nMonth:%d\nDate:%d\nHour... d\n" ,st.wYear,st.wMonth,st.wDay,st.wHour,st....
    }




    SYSTEMTIME looks like this:


    typedef struct _SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
    } SYSTEMTIME;
     
    Exorcist, May 31, 2009 IP