i wanted to print random line from a file. i knows how to print out the whole file but doesnt know how should i do to print a random lines from a file!!! hope someone can give me some ideals or an example. thanks!

Recommended Answers

All 2 Replies

Read whole file and store its content into array of string or vector line by line. After that you may choose random index.

yeah I dont think there is built in library to randomize lines... as adatapost pointed you can store each line into an array and then randomize the index

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.