When you call srand()
inside of a function, does it only seed rand()
inside of that function?
Here is the function main
where srand()
is called.
int main(){
srand(static_cast<unsigned int>(time(0)));
random_number();
}
void random_number(){
rand();
}
The function random_number
where rand()
is used is outside of where srand()
was called.
So my question is - If you seed rand()
by using srand()
, can you use the seeded rand()
outside of where srand()
was called? Including functions, different files, etc.