C
CBFalconer
Ioannis said:CBFalconer said:Ioannis Vranos wrote:
Correction:
array_2d[0] is an array of 5 ints.
array2d[0] is an array of 5 ints and it "behaves" (I do not know
the accurate technical term)as a pointer to array_2d[0][0], that is
*(array_2d[0]) is array_2d[0][0].
No. Don't drop the details. *(array_2d[0]) is a pointer to an
array of 5 ints. array_2d[0][0] is an int. Just one.
Actually my correction with addition of parentheses was not needed.
Given: int array_2d[10][5];
array_2d behaves like a pointer to an array of 5 ints.
array2d_[0] behaves like a pointer to array_2d[0][0];
No it isn't. For example (remembering that array_2d[0][0] is an
int) try the following:
[1] c:\c\junk>cat junk.c
#include <stdio.h>
int testfunct(void) {
int array_2d[10][5] = {{0}};
int test;
printf("sizeof array_2d[0] is %d\n",
(int)(sizeof array_2d[0]));
test = array_2d[0];
return 1;
}
int main(void) {testfunct(); return 0;}
[1] c:\c\junk>cc junk.c
junk.c: In function `testfunct':
junk.c:9: warning: assignment makes integer from pointer without
a cast
[1] c:\c\junk>a
sizeof array_2d[0] is 20