Posted: Mon Jul 02, 2012 12:05 am Post subject: 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 <iostream>
using namespace std;
int array[3];
int main()
{
for (int x = 0 ; x <=2 ; x++)
cout <<"Enter an integer ==> ";
cin >> array[x];
}
thanks in advance for any help[syntax=""][/syntax][syntax=""][/syntax]
code:
Sponsor Sponsor
Tony
Posted: Mon Jul 02, 2012 12:15 am Post subject: RE:user inputing values of an array
The problem is that for line
code:
cin >> array[x];
variable x does not exist (it was never declared in the current scope).