Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!mintaka!bloom-beacon!scs From: scs@athena.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: randomness Message-ID: <1990Apr11.001355.25937@athena.mit.edu> Date: 11 Apr 90 00:13:55 GMT References: <21274@eerie.acsu.Buffalo.EDU> <4878@helios.TAMU.EDU> Sender: news@athena.mit.edu (News system) Reply-To: scs@adam.mit.edu (Steve Summit) Organization: Massachvsetts Institvte of Technology Lines: 27 In article <4878@helios.TAMU.EDU> john@stat.tamu.edu (John S. Price) writes: >srand(time(NULL)); Make that #include srand((int)time((time_t)NULL)); This is not mere pedantry; it does make a difference. I'm posting this reminder only because this code matches the one time I ever got burned by a realio, trulio int/pointer mismatch, and in case there is anyone out there who still isn't convinced that proper pointer casts are in fact necessary in function call arguments. Somehow I forgot the cast one day and typed srand(time(NULL)) into the planet's lowest quality/popularity ratio computer (the PC) and compiled using a "memory model" in which ints and pointers are of different size. Since the designers of that machine apparently believed that protection mechanisms were only necessary in the antique mainframe computers which the PC revolution repudiated, the result of this mistake (on the PC) is not "Segmentation violation (core dumped)" but rather a hung machine, which must be power-cycled and rebooted. Watch those NULL pointers, folks. (Yes; prototypes might have helped.) Steve Summit scs@adam.mit.edu