Outputting random lines from a .txt file

Hey

How do you output 5 random lines of text from a .txt file on C++ ?

Thanks


Hmm, one "gimme" is enough. http://www.cplusplus.com/forum/general/11238/

You do know how to open a file and read lines, right?

I recommend you use a std::vector <std::string> lines; to store the lines in the file, then use rand() to choose lines at random to print.
Topic archived. No new replies allowed.