I'm having trouble with this struct array.. The first time it asks for an input, if the person were to type "1 2 3 4" it would have entered the input for each part of the array and skip to line 29 and display the final output
int main()
{
struct Person
{
string name;
string color;
};
Person person[2];
int i = 0;
while (i < 2)
{
cout << "name: ";
getline(cin, person[i].name, '\n');
cout << "color:";
getline(cin, person[i].color, '\n');
i = i + 1;
}
cout << endl;
i =0;
while (i <=1)
{
cout << person[i].name << " " << person[i].color << endl;
i = i + 1;
}
return 0;
}