mardi 1 juin 2021

I cannot write time(NULL) in srand() [closed]

I include these headers:

#include <iostream>
#include <vector>
#include <iomanip>
#include <random>
#include <cstdlib>
#include <ctime>

and this is a part of my code:

void Reservation::randomReservationNumber()
{
    srand(time(NULL));
    for (size_t i = 0; i < 8; ++i)
        reservationNumber[i] = rand() % 10;
}

there is an error at time which says C++ expression preceding parentheses of apparent call must have (pointer-to-) function type

How should I do if I want to summon a real random number?
What situation will cause this error?




Aucun commentaire:

Enregistrer un commentaire