Skip to content

Instantly share code, notes, and snippets.

@billowdood
Last active August 29, 2015 14:14
Show Gist options
  • Save billowdood/5e530b694ac536488d5f to your computer and use it in GitHub Desktop.
Save billowdood/5e530b694ac536488d5f to your computer and use it in GitHub Desktop.
Basic random generation in c
//Standard stuff
#include <stdio.h>
// rand(),srand()
#include <stdlib.h>
//time()
#include <time.h>
/*
References:
http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c
http://stackoverflow.com/questions/15458393/implicit-declaration-of-function-time-wimplicit-function-declaration
*/
int main(int argi,char** args){
srand(time(NULL));
int r = rand();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment