I am in the process of adding a string to an array, followed by a line with four integers. I can get them to all enter into the arrays and they output correctly... almost. The strings are cut-off after the first whitespace. As a result they do not display properly.
The >> operator stops reading as soon it encounters a space character.
By doing ss >> name[counter]; you only get the first word of ss.
To correct that you must do
I attempted both of these.
Both gave me a similar output, just the 4 numbers on the last line of the text file. So I'm unsure what to do.
Modifying the output a bit it just doesn't give anything for the name array.
Edit: I decided that, due to time constraints, I would replace all spaces in the middle of the names with periods. I'm still curious how to fix this though.
I tested your program with the modifications I suggested, and it works perfectly.
I think the only reason it can fail is if there are empty lines before what you want to read.
Taking that into account, here is a code that should work:
1 2 3
in >> name[counter]; // skips empty lines and blank characters until it finds a word
getline(in, line); // get the remainder of the line
name[counter] += line; // concatenate both strings