0

What I want to do is read a whole paragraph of text from a custom file. How would I do this without doing something silly like this?

while(someFile >> word1 >> word2 >> word3){
    //etc.
}

I need to be able to read 3 numbers for todays date, then read a whole paragraph, then another whole paragraph, and then repeat it.

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Zssffssz
0

Well you could setup something like this :

ifstream qwer ("p.txt");
Int number;
String paragraph;
qwer>>number;
getline(paragraph, qwer); // repeat for each line of paragraph with amend on or with a different  variable ll

The advantage of using amend is that you could just send it throug a loop instead of typeing it for each line.

0

Well you could setup something like this :

ifstream qwer ("p.txt");
Int number;
String paragraph;
qwer>>number;
getline(paragraph, qwer); // repeat for each line of paragraph with amend on or with a different  variable ll

The advantage of using amend is that you could just send it throug a loop instead of typeing it for each line.

How would I use that in the while loop though?

0

Well you could increment a number each loop (variable++) and when it reaches a point (while(variable!=5)) it breaks out of the loop.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.