Results 1 to 4 of 4

Thread: [RESOLVED] MS VC++ Error?

Threaded View

  1. #1

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444

    [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?
    Last edited by Rick Bull; Aug 30th, 2002 at 11:38 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width