Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles; site uokvax.UUCP Path: utzoo!linus!decvax!harpo!ulysses!burl!we13!ihnp4!inuxc!pur-ee!uiucdcs!parsec!ctvax!uokvax!jab From: jab@uokvax.UUCP Newsgroups: net.unix-wizards Subject: Re: question about ctime(3) and time(2) - (nf)Þ Message-ID: <6200023@uokvax.UUCP> Date: Tue, 3-Apr-84 12:01:00 EST Article-I.D.: uokvax.6200023 Posted: Tue Apr 3 12:01:00 1984 Date-Received: Sun, 15-Apr-84 01:32:25 EST References: <442@sri-arpa.UUCP> Lines: 52 Nf-ID: #R:sri-arpa:-44200:uokvax:6200023:000:1326 Nf-From: uokvax!jab Apr 3 11:01:00 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