How can I access the system date I tried with dos.h but I wish to know a little simpler method.
Please help.
How can I access the system date I tried with dos.h but I wish to know a little simpler method.
Please help.
There's the function time() that takes a time_t struct in time.h.
Sorry, time_t is a long int not a struct, and the time function takes a pointer to this long int. You'll have to use other functions declared in time.h to format this value.
struct tm * timestruct;
time_t totalseconds;
char * timestring;
time(&totalseconds) ; //Stores the long time in totalseconds
timestruct = localtime(&totalseconds); //Creates a struct containing time data
timestring = asctime(timestruct); //Creates a character string representing the time
cout << timestring << "\n"; //Outputs the time