I am wondering why my file input doesn't work when I use getline()
. I tried temp
to get rid of spaces, but that did work either.
void getKittenFromFile(string file, roster& kitt) {
string temp;
ifstream inFS;
int i = kitt.size;
inFS.open(file);
if (!inFS.is_open()) {
cout << "Error! File not found." << endl;
}
else {
while (!inFS.eof() && kitt.size < 10) {
getline(inFS, kitt.kittens[i].name);
getline(inFS, kitt.kittens[i].color);
inFS >> kitt.kittens[i].score;
i++;
kitt.size++;
}
The file looks like this:
Willow
dark brown
66
jack
brown
84
Will
blue
6