How to get the time...
Tom Christiansen
tchrist at convex.COM
Tue Feb 19 05:21:48 AEST 1991
>From the keyboard of rmacgreg at cs.strath.ac.uk (Sorcerer):
:I'm trying to get the time and date using the ctime() function, but I've come
:up against a rather large problem... Ctime() expects a long int as an
:argument, but the manual doesn't say how or where you get this long int from.
My manual says:
char *ctime(const time_t *clock);
usually you feed it something from the output of time(3) or perhaps
the st_[acm]time fields from a stat(2) call. My time(3) looks like
this:
time_t time(time_t *tloc);
So in general, do this:
time_t now = time(0);
char *cnow = ctime(&now);
replace time_t with long on old systems.
--tom
--
Tom Christiansen tchrist at convex.com convex!tchrist
"All things are possible, but not all expedient." (in life, UNIX, and perl)
More information about the Comp.lang.c
mailing list