vib said:
Hi there,
i) Is there any other way to replace the rand()of standard C lib?
There is no way to replace any part of the Standard
library -- rand(), printf(), exit(), whatever -- while
remaining within the scope of Standard C. A particular
C implementation may provide ways to do this, but if so
they are specific to the implementation and not defined
by the C language; search the implementation's documentation
or ask in a forum that discusses the implementation in
question.
However, it is perfectly all right to create your own
myrand() function that generates pseudo-random numbers using
whatever method you choose. Many methods exist, each with
its own strengths and weaknesses.
ii) How efficient is the rand()?
Each C implementation supplies its own version of rand(),
and the versions need not be identical. Thus, the question
can only be answered in terms of a particular implementation,
not in terms of the C language itself.
If you want an extremely efficient source of pseudo-random
numbers, feel free to use this one:
int myrand(void) { return 0; }
This is about the fastest you're likely to get, although the
statistical properties of the generated number sequence may
be inadequate for some applications ...
(In other words, your question cannot be important until
many other questions have been asked and answered.)