i'd like to run this in my int main() multiple times, generating a new random number every time. It generates a new numbers on every new build, however i want it to generate different numbers during the same build, thanks
//my random number generator:
int randomNumber()
{
srand(time(NULL));
for (int t = 0; t < 10; t++)
{
int random_x;
random_x = rand() % 15;
return random_x;
}
//my main:
int main()
{
int num1 = randomNumber();
int num2 = randomNumber();
int num3 = randomNumber();
std::cout << num1 << " " << num2 << " " << num3 << std::endl;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire