Re: [Dev-C++] Generate random number
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Matt V. <mat...@ya...> - 2006-09-28 06:02:35
|
You could seed rand() with system time:
#include <stdio.h>
#include <time.h>
time_t ltime;
unsigned int seconds = time(<ime);
srand(seconds);
int num = rand();
int main()
{
printf("Random number is %d", num);
return(0);
}
It would still be a "pseudo random number", but it ought to be different most every time. Search Google for random number generation solutions of far greater complexity.
Matt
http://www.cminusgames.com
---------------------------------
How low will we go? Check out Yahoo! Messengers low PC-to-Phone call rates. |