Search code examples
crandomnumberssrand

How to generate random numbers with rand() without time.h in C


How to generate random numbers with rand() and srand() without time.h in C ?


Solution

  • You could try givin another seed to the random generator like the program's pid.

    srand(getpid());
    int num = rand();