Hi,
I need a simple code to display the current date and time in c++.I am new to c++.please do help me.
Thanks.
to display current date and timesimple code to display the current date and time in c++
Page 1 of 1
1 Replies - 17353 Views - Last Post: 02 January 2008 - 10:28 AM
Replies To: to display current date and time
#2
Re: to display current date and time
Posted 02 January 2008 - 10:28 AM
vinu, on 2 Jan, 2008 - 04:13 AM, said:
Hi,
I need a simple code to display the current date and time in c++.I am new to c++.please do help me.
Thanks.
I need a simple code to display the current date and time in c++.I am new to c++.please do help me.
Thanks.
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
time_t tim; //create variable of time_t
time(&tim); //pass variable tim to time function
cout << ctime(&tim); // this translates what was returned from time() into a readable format
return 0;
}
This post has been edited by tralfas: 02 January 2008 - 10:30 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|