[RESOLVED] MS VC++ Error?
Hi, I'm new to C++, and I was just testing out arrays. I made a 2D array, and had the following code to get the user to fill the arrays, and then read it back:
Code:
for (USINT loopcounter1 = 0; loopcounter1 < 3; loopcounter1++)
{
for (USINT loopcounter2 = 0; loopcounter2 < 3; loopcounter2++)
{
cout << "Please enter a number for " <<
"[" << loopcounter1 << "]" <<
"[" << loopcounter2 << "]: ";
cin >> numbers[loopcounter1][loopcounter2];
}
}
cout << "Thank you\n";
for (USINT loopcounter1 = 0; loopcounter1 < 3; loopcounter1++)
{
for (USINT loopcounter2 = 0; loopcounter2 < 3; loopcounter2++)
{
cout << "Item [" << loopcounter1 << "]" <<
"[" << loopcounter2 << "] = " <<
numbers[loopcounter1][loopcounter2] <<
endl;
}
}
But Microsoft Visual C++ gave me a compile error at the bolded text that USINT loopcounter1 had already been declared on the first loop. I may be wrong here but I should declare it again shouldn't I as it's gone out of scope and has been destroyed. I compiled the same prog in Dev-C++ and it compiled without an error, who's right? :confused: