Skip to content

Instantly share code, notes, and snippets.

@yellowbyte
Created December 5, 2017 05:23
Show Gist options
  • Save yellowbyte/4c36b9fffa73d79fa739f75a5ea951c9 to your computer and use it in GitHub Desktop.
Save yellowbyte/4c36b9fffa73d79fa739f75a5ea951c9 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(){
// use current time to seed the prng used by rand()
// if srand is not called (default: srand(1)), rand() will always generate the same sequence
srand(time(0));
for(int i=0; i<3; i++)
printf("%d\n", rand());
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment