Xref: utzoo comp.unix.xenix:8571 comp.lang.c:23757 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!samsung!brutus.cs.uiuc.edu!psuvax1!wuarchive!swbatl!texbell!vector!attctc!ozdaltx!root From: root@ozdaltx.UUCP (root) Newsgroups: comp.unix.xenix,comp.lang.c Subject: random number, how do I do it? Message-ID: <5726@ozdaltx.UUCP> Date: 16 Nov 89 00:58:10 GMT Organization: OZ BBS - Dallas, TX Lines: 31 I am trying to write some code to generate a random number that would fall between 0 and 65,000. I know there is something I'm missing here, but can't seem to pin it down. I feel like the problem is in the type declarations, but have tried most combinations with not a lot of success. Any suggestions? Sample code: ------------------------------ #include main() { extern unsigned short rand(); extern unsigned long time(); unsigned short offset; /* generate a random number using time and pid as seed */ while(1){ srand((unsigned)getpid() + (unsigned)time(NULL)); offset = rand(); printf("NUMBER=%ld\n",offset); sleep(1); } } ------------------ Thanks Scotty AIDS INFORMATION EXCHANGE BBS (214) 247-2367/247-5609 "Education is the best weapon" {ames,rutgers,texsun,smu}!attctc!ozdaltx!sysop