#pragma warning(disable:4996)
#include <iostream>
#include <fstream>
#include <string>


using namespace std;

{
 fstream inputStream;

 inputStream.open("player.txt");
 int numScores;
 inputStream >> numScores;


 for (int i = 0; i < numScores; i++)
 {
  string name;
  int score;             //이부분

  inputStream >> name;
  inputStream >> score;
  cout << name << "," << score << endl;
 }
 inputStream.close();
}


변수선언을 반복문 안에서 해도 실행이 되던데 변수선언 원래 중복으로 하면 오류떠야 정상아님?

책에도 답이 이렇게 나와있고 이거 왜이러는건지좀 답변좀 해주면 감사