question about ctime(3) and time(2) - (nf)�

jab at uokvax.UUCP jab at uokvax.UUCP
Wed Apr 4 03:01:00 AEST 1984


#R:sri-arpa:-44200:uokvax:6200023:000:1326
uokvax!jab    Apr  3 11:01:00 1984

/***** uokvax:net.unix-wizar / sri-arpa!ARPA / 12:00 am  Apr  2, 1984 */
time(2) in unix v6 says it takes as argument a long, and returns suitable
information for ctime(3) to return a character pointer.  However, I'm
getting strange results when I try to do a couple of things.

executing
main()
{
          long i;
          char *t;

          t = ctime(time(&i));
}
results in a core dump.  The sources to date(1) show time(2) as taking
int [2] rather than long.  So when I tried the following, I got a bus
error core dump.

main()
{
          int i[2];
          char *t;

          t = ctime(time(i));
          puts(t);
}

when substituting t[80] for *t, it did not compile, claiming that the
line which the assignment to t is on needed an lvalue (i presume it is
the "t" that doesn't have one).

Am I doing something wrong, or is unix?  Should I be loading some
special library?
-------
/* ---------- */

No, no, no!

time(2) returns a long. Fine. Both time(2) and ctime(3) take pointers
to longs. On the older versions of the pdp-11, longs were passed as
a pointer to two integers, and so something like the above worked, sort of.

If you run lint(1) on the above program, it will howl and bitch until
doomsday.

(For those of you who use "time_t", fine, just "s/long/time_t/g" in the
above.)

	Jeff Bowles
	Lisle, IL



More information about the Comp.unix.wizards mailing list