¿Por qué rand () devuelve el mismo valor usando srand (tiempo (nulo)) en este bucle for?
Tengo el siguiente 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");
}
La salida es el mismo número repetido seis veces, me gustaría que imprima una combinación de números.