| www.delorie.com/archives/browse.cgi | search |
| Date: | Tue, 01 Nov 1994 16:06:54 +0100 |
| From: | Csizmadia Peter <cspt AT ludens DOT elte DOT hu> |
| To: | djgpp AT sun DOT soe DOT clarkson DOT edu |
| Subject: | Is it random number sequence? |
int main(int argc, char* argv[])
{
int i;
srand(atoi(argv[1]));
for(i=0; i<30; ++i)
printf(" %d", rand()&3);
putchar('\n');
}
This simple program produces the following "random number sequence"
for any seed number:
1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2 3 0 1 2
Is it the normal behavior of the rand() function in GNU C?
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |