S
subramanian100in
The following portion is from c-faq.com - comp.lang.c FAQ list ·
Question 6.13
int a1[3] = {0, 1, 2};
int a2[2][3] = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap)[3]; /* pointer to array [3] of int */\
ap = &a1;
printf("%d\n", **ap);
ap++; /* WRONG */
Here why is incrementing ap ie 'ap++' mentioned as WRONG ? Isn't it
similar to
int i_int = 100;
int *p = &i_int;
p++;
Here we cannot dereference 'p' but incrementing 'p' only once, is
allowed. Similarly,
ap is assigned '&a1'. Then we increment ap only once. Why is this
WRONG ?
Kindly clarify.
Thanks
V.Subramanian
Question 6.13
int a1[3] = {0, 1, 2};
int a2[2][3] = {{3, 4, 5}, {6, 7, 8}};
int *ip; /* pointer to int */
int (*ap)[3]; /* pointer to array [3] of int */\
ap = &a1;
printf("%d\n", **ap);
ap++; /* WRONG */
Here why is incrementing ap ie 'ap++' mentioned as WRONG ? Isn't it
similar to
int i_int = 100;
int *p = &i_int;
p++;
Here we cannot dereference 'p' but incrementing 'p' only once, is
allowed. Similarly,
ap is assigned '&a1'. Then we increment ap only once. Why is this
WRONG ?
Kindly clarify.
Thanks
V.Subramanian