What’s the Right Way to use the rand() Function in C++?

Option 2 isn’t difficult, here you go:

srand(time(NULL));

you’ll need to include stdlib.h for srand() and time.h for time().

Leave a Comment