What must be included in my program to get the current date in my system.
God Bless you all!
Getting Current System TimeUsing C in turbo C
Page 1 of 1
4 Replies - 69925 Views - Last Post: 22 December 2006 - 10:53 PM
Replies To: Getting Current System Time
#2
Re: Getting Current System Time
Posted 22 December 2006 - 08:05 PM
cire_1803, on 23 Dec, 2006 - 08:20 AM, said:
What must be included in my program to get the current date in my system.
God Bless you all!
God Bless you all!
Finding Current Date
#3
Re: Getting Current System Time
Posted 22 December 2006 - 09:39 PM
Xing, on 22 Dec, 2006 - 08:05 PM, said:
cire_1803, on 23 Dec, 2006 - 08:20 AM, said:
What must be included in my program to get the current date in my system.
God Bless you all!
God Bless you all!
Finding Current Date
How to convert this code into turbo C code, because i am using C not C++.
#4
Re: Getting Current System Time
Posted 22 December 2006 - 10:27 PM
#20
Re: Getting Current System Time
Posted 22 December 2006 - 10:53 PM
You need to include TIME.H and then you can use the following.
You need to call function asctime and localtime to retrieve the time and format it in a readable manner. You create a pointer to type char to store the memory address of the resulting value that is returned. Then you can just display it using the string format specifier.
#include <stdio.h>
#include <time.h>
int main ()
{
char *date;
time_t timer;
timer=time(NULL);
date = asctime(localtime(&timer));
printf("Current Date: %s", date);
getchar();
return 0;
}
You need to call function asctime and localtime to retrieve the time and format it in a readable manner. You create a pointer to type char to store the memory address of the resulting value that is returned. Then you can just display it using the string format specifier.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|