cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Outputting random lines from a .txt file
Outputting random lines from a .txt file
May 23, 2009 at 12:21am UTC
wizard25
(18)
Hey
How do you output 5 random lines of text from a .txt file on C++ ?
Thanks
May 23, 2009 at 12:39am UTC
Duthomhas
(13206)
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.