
-----------------------------------
marcus
Mon Jul 02, 2012 12:05 am

user inputing values of an array
-----------------------------------
I want to write a program which allows a user to enter the values of an array using a for loop, however I am getting an error which says "name lookup of x changed for ISO 'for' scoping"
i am new to C++ (two weeks) and i have NO clue what this means. here is my code

[code]

#include 

using namespace std;

int array[3];

int main()
{
    for (int x = 0 ; x  array[x];

}
[/code]

thanks in advance for any help[syntax=""][/syntax][syntax=""][/syntax][code][/code]

-----------------------------------
Tony
Mon Jul 02, 2012 12:15 am

RE:user inputing values of an array
-----------------------------------
The problem is that for line
[code]
cin >> array[x]; 
[/code]
variable x does not exist (it was never declared in the current scope).

http://en.wikipedia.org/wiki/Scope_(computer_science)
