.TXT file output

Hey

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

Thanks
umm well im just gonna wing this cause ive never done it before,

set your srand((unsigned)time(0));
rand_NUM[5];
for loop
rand_NUM[i] = (rand()%+(amount of lines from text file))+1 use a counter with a while loop
fstream file("file.txt");
while loop (getline(File,line,'#'))
establish your counter
if(line == rand_NUM[i])
cout<<line<<endl;

i dont really know but probably something along those lines, jus play around with it

Topic archived. No new replies allowed.