unexplained nested for loops

closed account (1AozwA7f)
I expected this code to return to prompt for a second name. It displays the prompt, but continues right to enter score for the next player:

Player 0 enter your name: Mathew
Mathew enter your score: 10
Mathew enter your score: 20
Mathew enter your score: 30
Player 1 enter your name: enter your score:

1
2
3
4
5
6
7
8
9
10
  for (int j = 0; j < 3; ++j) {
		string name;
		cout << "Player " << j << " enter your name: ";
		getline(cin, game_scores[j].player_name);
		
		for (int i = 0; i < 3; i++) {
			cout << game_scores[j].player_name << " enter your score: ";
			cin >> game_scores[j].score[i];
		}
	}
Topic archived. No new replies allowed.