Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Created September 23, 2012 06:55
Show Gist options
  • Select an option

  • Save Watson1978/3769148 to your computer and use it in GitHub Desktop.

Select an option

Save Watson1978/3769148 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
srand(time(NULL));
printf("rand = %d", rand() % 7);
}
@Watson1978

Copy link
Copy Markdown
Author
$ clang rand.c
$ ./a.out
rand = 4
$ ./a.out
rand = 4
$ ./a.out
rand = 4
$ ./a.out
rand = 4
$ ./a.out
rand = 4

always generated 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment