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

L. Hirschbiegel lothar at tmcsys.UUCP
Wed May 22 08:27:59 AEST 1991


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

You're a cousin of "lint", aren't you :-) ?

>Note that the argument to the time system call is a `long *', aka
>pointer to long. 

Ever tried to RTFM for yourself? 

	  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.

If you still don't understand: I'll help you! 
For this little test program:

main()
{
time(0L);
time((long *)0);
}

the assembler output from my C compiler is:

	.file	"main.c"
gcc_compiled.:
.text
	.align 4
.globl main
main:
	pushl %ebp
	movl %esp,%ebp
	pushl $0
	call time
	pushl $0
	call time
.L1:
	leave
	ret

>Repeat after me: POINTER to long.

Repeat after me: IT DOESN'T MATTER :-)

>I'm always wondering why people can't grasp
>the difference between a plain integer, a long and pointers to any of it.

So do I...

>-- 
>Martin Weitzel, email: martin at mwtech.UUCP, voice: 49-(0)6151-6 56 83

Lothar Hirschbiegel
-- 
-----------------------------------------------
L. Hirschbiegel, AEG - A84, Frankfurt (Germany) 
email: unido!aega84!lh     tel: -49-69-66414316  
-----------------------------------------------



More information about the Comp.lang.c mailing list