vendredi 12 février 2021

What is default seed?

When I call the following function:

printf("%d\n", rand())
srand(0);
printf("%d\n", rand());

I consistently get the following output:

1804289383
1804289383

What is this number representing before the srand()? And if the point is to make the srand required. Why isn't it initialized to something like 0 or -1 or whatever?




Aucun commentaire:

Enregistrer un commentaire