I'm trying to write a program that takes a line of text from a .txt file and then writes that line into an array of strings.
So far I figured out to put one word of text in each row of the Array, but I want to put a whole line so:
"first line from text" will be put into textArray[0]
"Second line from text" will be put into textArray[1]
etc...
Using a for loop is poor design. Your loop is expecting exactly 100 lines.
Better design is to use a while loop:
1 2 3 4
int i = 0;
while (i < 100 && getline(cin,textArray[i++]))
;
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.