Por que rand () retorna o mesmo valor usando srand (time (null)) neste loop for?
eu tenho o seguinte código
#include<iostream>
#include "time.h"
using namespace std;
void printRandomNumber()
{
srand(time(NULL));
cout << rand() % 3;
}
int main()
{
for(int i=0; i<=5; i++)
{
printRandomNumber();
}
system("pause");
}
A saída é o mesmo número repetido seis vezes, eu gostaria de imprimir uma mistura de números.