I would like to go through how rand() and srand() functions are implemented and would like to tweak the code to modify it to my requirements. Where can i find the source cod
The glibc one (used by gcc) is the simple formula:
x = 1103515245 * x + 12345
wrapping around at 232, as shown here. You can just set x
as the seed then keep calling a function to evaluate that expression (and update the seed).
But you should be aware the linear congruential generators like this are considered adequate but not ideal.
While the only ideal random number generator would be perfectly random, the Mersenne Twister probably comes closer.