Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Novice C++ question

Author: Brian Kostick

Date: 15:16:49 05/11/05

Go up one level in this thread


On May 11, 2005 at 11:14:52, S J J wrote:

>I have not been able to find a C++ command that returns the time.
>Does anyone know of one?
>
>Thanks,
>Steve

Hi Steve,

  YOu have good help so far. He's something a little more. Hard to say if useful
for what you are doing, since we do not know what it is... Should be portable
and adapt to C++ easy enough. BK


#include <stdio.h>
#include <time.h>

int main(int argc, char *argv[])
{
	char timeBuff[32];
	char dateBuff[32];

	time_t tt;
	time(&tt);

	strftime(timeBuff, sizeof(timeBuff), "%H:%M:%S", localtime(&tt));
	strftime(dateBuff, sizeof(dateBuff), "%m/%d/%y", localtime(&tt));

	printf("%s\n%s\n", timeBuff, dateBuff);

    getchar( );
    return(0);
}



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.