So I got this code online, but it doesn't give a random number every time you call it. I'm trying to make noughts and crosses (agains't a bot) and this will be the code to let the bot decide where to place it's symbol, but every time I call it in an if statement (if (!playerTurn)) it gives the same number it gave the time before. This is the code I got so far.
{
srand(time(NULL));
int rand = std::rand() % 8;
cout << "Computer heeft geplaatst op positie " << rand << "\n";
printBoard();
playerTurn = true;
}