fork(1) download
  1. #include <stdio.h> // printf()
  2. #include <stdlib.h> // srand(), rand()
  3. #include <time.h> // time()
  4.  
  5. int main(void) {
  6. srand(time(0));
  7. printf("%d\n", rand()); // <== random between 0 and RAND_MAX (from <limits.h>)
  8. printf("%d\n", rand()); // <== random between 0 and RAND_MAX (from <limits.h>)
  9. srand(time(0));
  10. printf("%d\n", rand()); // <== random between 0 and RAND_MAX (from <limits.h>)
  11. printf("%d\n", rand()); // <== random between 0 and RAND_MAX (from <limits.h>)
  12. return 0;
  13. }
Success #stdin #stdout 0s 2112KB
stdin
Standard input is empty
stdout
1492746333
1787353041
1492746333
1787353041