Pages

Showing posts with label date and tome macro. Show all posts
Showing posts with label date and tome macro. Show all posts

Sunday, August 28, 2011

How to Show Date and Time with C and C++

The following program will show how to print system date and time using C and C++. To show date and time, this program is using __DATE__ and __TIME__ macros. These macros will show date and time on the screen.

#include<stdio.h>
#include<conio.h> 

void main()
{
    clrscr();
    textcolor(6);
    cprintf("Showing Executing Date and Time \n");
    printf("\n") ;
    textcolor(2);
    cprintf("    Date: %s ",__DATE__);
    printf("\n") ;
    textcolor(4);
    cprintf("    Time: %s ",__TIME__);
    getch();
}

Output