time(0L) - history of a misconception (was Re: SCO password generator)

Martin Weitzel martin at mwtech.UUCP
Tue May 21 20:03:31 AEST 1991


In article <588 at sherpa.UUCP> rac at sherpa.UUCP (Roger Cornelius) writes:
[...]
>	long seed = time(0L);
	                 ^^--------- wrong
	           time((long *)0);
	                ^^^^^^^^^--- right

Note that the argument to the time system call is a `long *', aka
pointer to long. Repeat after me: POINTER to long.

But I've seen this too often, even in examples printed in some manuals.
Though I had not much confidence into those particular manuals where
I found it (for reasons that probably aren't of any interrest to the
readers of this group), I'm curious if anybody has ideas from where this
misconception originated.

Or, if you have two minutes and you have some source code from which you
suppose that it contains a time system call, just grep through it and
look if it's done right. I'm always wondering why people can't grasp
the difference between a plain integer, a long and pointers to any of it.
-- 
Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83



More information about the Comp.lang.c mailing list