0

Hello, I've been trying to figure out this problem for a while now and cant figure it out. What im trying to do is assign a value to a location in an array. SIMPLE! isnt it. well heres my problem.
int main(){
int array[1][1];
.
.
.
array[0][1]=-1;
array[1][0]=-2;

cout<<array[0][1]<<" "<<array[1][0];
.
.
.
}
the output is -2 -2. I have no clue as to whats going on. Ive tried changing it to array[1,0] but i got some errors. Does anyone know whats going on?

Thanks in advance.

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

First, the array you declared has only ONE element in each of the two dimensions. If you want them to have two elements then declare it like this: int array[2][2]; >> Ive tried changing it to array[1,0]
That doesn't work in C or C++.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.