Xref: utzoo comp.unix.sysv386:8369 comp.lang.c:39549 Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!mcsun!ukc!ox-prg!msc7.comlab!imc From: imc@prg.ox.ac.uk (Ian Collier) Newsgroups: comp.unix.sysv386,comp.lang.c Subject: Re: time(0L) - history of a misconception (was Re: SCO password generator) Message-ID: <813.imc@uk.ac.ox.prg> Date: 23 May 91 10:45:58 GMT References: <1991May14.040042.15199@jpradley.jpr.com> <588@sherpa.UUCP> <1141@mwtech.UUCP> <381@tmcsys.UUCP> Sender: news@prg.ox.ac.uk Reply-To: imc@prg.ox.ac.uk (Ian Collier) Organization: Oxford University Computing Laboratory, UK Lines: 44 In article <381@tmcsys.UUCP>, lh@aega84.UUCP (L. Hirschbiegel) wrote: [about the argument of time()] > NAME > time - get time > > DESCRIPTION > The time system call returns the value of time in seconds > since 00:00:00 Greenwich Mean Time (GMT), January 1, 1970. > > If tloc is non-zero, the return value is also stored in the > ^^^^^^^^^^^ > location to which tloc points. Obviously the writers of your manual don't know the difference between a long and a pointer, then. Ours seems to have it about right... SYNOPSIS ... time_t time(tloc) time_t *tloc; DESCRIPTION time() returns the time since 00:00:00 GMT, Jan. 1, 1970, measured in seconds. If tloc is non-NULL, the return value is also stored in the ^^^^ location to which tloc points. >For this little test program: ... >the assembler output from my C compiler is: ... All that means is that your computer represents a NULL pointer by zero (also evident from your manual page). So for time(0L) it pushes a long zero, and for time((long *)0) it pushes a null pointer, which is just a long zero. That will happen on most computers, but not all. (As someone has pointed out, however, if a prototype for time() is in scope then a zero will be converted into a null pointer, probably without a warning message). Ian Collier Ian.Collier@prg.ox.ac.uk | imc@ecs.ox.ac.uk