C++ Programming/Code/Standard C Library/Functions/srand
Tools
General
Sister projects
In other projects
| Syntax | #include<cstdlib>voidsrand(unsignedseed); |
The function srand() is used to seed the random sequence generated byrand(). For any givenseed,rand() will generate a specific "random" sequence over and over again.
srand(time(NULL));for(i=0;i<10;i++)printf("Random number #%d: %d\n",i,rand());