"Kristofer Berggren" <d9*****@dtek.c halmers.se> wrote in message >
I'm developing a simple application which uses rand() frequently,
and I was just wondering if there are any alternatives to generating
random numbers other than the in-built function in C? I'm using
GNU C/C++ compiler 3.3.1.
rand() works okay for me, but I suppose it has its limitations.
There are many ways of generating random numbers. The main limitation of
rand() is that it uses a 32 bit seed, which means that a maximum of 4
billion numbers can be generated before it cycles.
This means that if, say, you are generating cards for a gambling game,
someone with access to your source code could write down the first ten or so
cards, match up the sequence, and determine the eleventh - on which maybe a
huge stake rests.
That said, the inbuilt rand() is ok for most purposes, but for a better RNG
look up "random number generator" on google. It might also be a good idea to
look in the cryptography newsgroups.