Advertisement

current Time ?

Started by March 23, 2002 02:49 PM
3 comments, last by DonatO 22 years, 8 months ago
Hy ! How can I print on the screen, the current time, in a dos simple program ? thx !
umm, wot language?

What about me? What about Raven?
Advertisement
Look at MSDN, in particular the function localtime ().

Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

            #include <stdio.h>        #include <time.h>int main(){	time_t ttime;	tm*    pCurTime;	char   cTimeString[32];	//Get the current time	time(&ttime);	pCurTime = localtime(&ttime);	strftime(cTimeString, 32, "%m/%d/%Y at %H:%M:%S",pCurTime);        printf("The date and time are: %s", cTimeString);        return 0;}    


This outputs a time in the format "03/23/2002 at 12:31:44"

voila the current time and date. To learn more about the formatting of the string, look up strftime().

--------------------------

Those who dance are considered insane by those who cannot hear the music.

[edited by - terminate on March 23, 2002 4:59:03 PM]
Those who dance are considered insane by those who cannot hear the music.
Thx !!!!

This topic is closed to new replies.

Advertisement