Check out example codes for "can you use rand to read in from an external file inc++". It will help you in understanding the concepts better.

Code Example 1

string line;
int random = 0;
int numOfLines = 0;
ifstream File("file.txt");

    srand(time(0));
    random = rand() % 50;

while(getline(File, line))
{
    ++numOfLines;

    if(numOfLines == random)
    {
        cout << line;
    }

}

Learn ReactJs, React Native from akashmittal.com