I am given a file with about ten lines and I need to fill a string array with all the items (except for the first) from a given line.
If the text file looked like:
Word abc def
Ghi jkl mno
Pqr stu vwx
And if i wanted to fill a string array with items from line 2, it needs to look like:
(jkl mno)
How do I access a certain line in the file and fill the string array?
This is what I have so far
string str;
getline(infile, str);
while(!(infile.eof())&&(str[0]!= firstLetterOfLine))
{
getline(infile, str);
}
I believe that this will give me the correct line of the file. Now, I am trying to figure out how to add each word into a string array.
My plan is to make substrings and send those to array[i] for every i less than the size of the array, but I am not sure how to choose the positions for the beginning and end of the substring. I'm not looking for anyone to write the code for me, just a hint in the correct direction.