samedi 28 mai 2016

Getting a random set of words from file

I am making a "mini-game" project and I need to retrieve a random set of 10 words from a file I made. The words (around 30) are separated by the return key in the text file. The code retrieves 10 words like it's supposed to, but I need it to start at a random point within the text file.

EDIT: Sorry guys, I'm new. Here's the code.

cout << "Connecting to user...\n" << endl;
        sleep(1);
        inFile.open("Novice.txt");

        for (int x = 0; x < 10; x++)
        {
            for (int y = 0; y < 4; y++)
            {
                inFile >> letter_Match[x][y];
                passwordList[x] += letter_Match[x][y];
            }
            cout << passwordList[x] << endl;
        }
        inFile.close();




Aucun commentaire:

Enregistrer un commentaire