Mail Archives: djgpp/1999/08/02/02:02:57.1
I figured this out BEFORE the reply contained below, but I do
thank you for the confirmation.
EUREKA! I did it...finally...
/* This DJGPP program PROPERLY displays the
Current Date/Time (as set by the PC's system time).
The purpose of this program is to simply demonstrate
how DJGPP compares to Borland (and other compilers)
in compatibility, compilation speed, execuation speed,
and a host of other details!
The following program clearly shows the proper way to use
the structures
struct tm *time_now;
time_t secs_now;
and the funcitons:
prinft, strcpy
time(),
localtime(),
strftime(); //a really jazzie way to output Date/Time !!
This actually compiles IDENTICALLY (ie: NO CHANGES) in
Borland 4.xx and 5.xx !!
*/
#include <stdio.h>
#include <string.h>
#include <time.h>
struct tm *time_now;
time_t secs_now;
int main(void) {
char buf1[100];
char buf2[100];
time(&secs_now);
time_now = localtime(&secs_now);
strcpy( buf1, asctime(localtime(&secs_now)) );
strftime(buf2, 80,
"It is %M minutes after %I o'clock (%Z) %A, %B %d 19%y",
time_now);
printf("The current date/time is %s", buf1 );
printf("The current date/time is %s", buf2 );
return 0;
}
/* Outputs:
The Current Date/Time!!
*/
===========================================================
On Sun, 01 Aug 1999 23:34:15 -0500, Weiqi Gao <weiqigao AT a DOT crl DOT com>
wrote:
>Rich wrote:
That was in reference to what another poster had said, somewhat
rudely. If you follow the ListServ messages, you'll understand.
>New comers are never treated harshly in this newsgroup. Considering
>that this news group has a fantastic FAQ, I don't think a "beginner"
>newsgroup would be necessary. And in general a group for "beginner"s
>would never work: who's going to ANSWER all the beginner questions?
>
>> I still would like to see a working example of strftime
>> since I haven't been successful getting the LIBC.hlp
>> example to work for me yet.
>
>time_t now;
>char buf[100];
>time(&now);
>strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", localtime(&now));
>
>This should give you something like "1999-08-01 22:59:56".
My web page:
http://members.tripod.com/~RadSurfer/
- Raw text -