1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| char wordComputer ()
{
srand(time(NULL));
int random,random1,random2;
int nombre(0);
random1=(rand());
random2=(rand());
random=((random1*random2)%361075); // pour avoir un nombre aléatoire assez grand, 361075 étant le nombre de mot dans le .txt
char chaine[255];
ifstream entree("dico.txt");
entree >> chaine;
while (nombre!=random)
{
entree >> chaine;
nombre++;
}
cout <<"le mot choisi est : " <<chaine << endl; // juste pour tester si le choix aléatoire marche bien.
entree.close();
return chaine;
} |
Partager