1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <cstdlib>
#include <string>
#include <fstream>
#include <ctime>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
string piocherMot(){
int posimot(0);
int taille(232578);
string ligne, returnmot;
ifstream flux("dico.txt");
if(flux){
srand(time(0));
posimot = rand() % 232578;
int i(0);
while(i != posimot){
getline(flux, ligne);
i++;
}
ligne = returnmot;
cout << ligne;
return ligne;
}
else{
cout << "Impossible d'ouvrir le fichier";
}
}
int main()
{
cout << piocherMot();
return 0;
} |
Partager