H
Henry
Hopefully you guys can give me some help on Multi-dimensional arrays....
I just read the section on it and here's why I am confused
Main()
int matrix [2][4];
{
{1, 2, 3, 4};
{10, 20, 30, 40};
}
^ That was Pratical C's explaination of how multidimensional arrays break
down. "a declaration of an array of dimension 2 whose elements are arrays
of dimension 4."
Ok this is why I am confused , I guess they mean by dimension 2 that it is
1's, and then 10's. So if it was dimension 4 as the first number it would
be 1's, 10's, 100's, 1000's ?? And with the second number being 4 that means
it continues for 4 numbers. If I am right (???) .. so if I wanted to put
something in that array I could put it at just the number 10 , but not 11 or
12?
Also another thing that confuses me is when they have an array say ... int
arr[4] and then they set a variable like this int [x] inside the array
later... obviously x would have to have a value between 0 and 4 correct?
So when you set x inside the array like that it just replaces one of the
sections of the array equal to its value.. let me try to explain what I
mean:
x = 3
arr[4] = arr[0], arr[1], arr[2], arr[3], arr[4]
arr[x] = arr[0], arr[1], arr[2], arr[x], arr[4]
Am I right? Or have I completly confused myself... either way I am still
very confused.
Thanks,
Henry
I just read the section on it and here's why I am confused
Main()
int matrix [2][4];
{
{1, 2, 3, 4};
{10, 20, 30, 40};
}
^ That was Pratical C's explaination of how multidimensional arrays break
down. "a declaration of an array of dimension 2 whose elements are arrays
of dimension 4."
Ok this is why I am confused , I guess they mean by dimension 2 that it is
1's, and then 10's. So if it was dimension 4 as the first number it would
be 1's, 10's, 100's, 1000's ?? And with the second number being 4 that means
it continues for 4 numbers. If I am right (???) .. so if I wanted to put
something in that array I could put it at just the number 10 , but not 11 or
12?
Also another thing that confuses me is when they have an array say ... int
arr[4] and then they set a variable like this int [x] inside the array
later... obviously x would have to have a value between 0 and 4 correct?
So when you set x inside the array like that it just replaces one of the
sections of the array equal to its value.. let me try to explain what I
mean:
x = 3
arr[4] = arr[0], arr[1], arr[2], arr[3], arr[4]
arr[x] = arr[0], arr[1], arr[2], arr[x], arr[4]
Am I right? Or have I completly confused myself... either way I am still
very confused.
Thanks,
Henry