Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikibooksThe Free Textbook Project
Search

C++ Programming/Code/Standard C Library/Functions/srand

From Wikibooks, open books for an open world
<C++ Programming |Code/Standard C Library |Functions

srand

[edit |edit source]
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());
Related topics
rand
(Standard C Time & Date functions)time
Retrieved from "https://en.wikibooks.org/w/index.php?title=C%2B%2B_Programming/Code/Standard_C_Library/Functions/srand&oldid=3676474"
Category:

[8]ページ先頭

©2009-2025 Movatter.jp