Thursday, March 24, 2011

Print out current time in C on Windows

  typedef struct _SYSTEMTIME {
       WORD wYear;
       WORD wMonth;
       WORD wDayOfWeek;
       WORD wDay;
       WORD wHour;
       WORD wMinute;
       WORD wSecond;
       WORD wMilliseconds;
    } SYSTEMTIME;

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

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


more info:
http://www.codersource.net/c/c-tutorials/c-date-and-time.aspx
 

No comments: