N
Neo
Hi Folks,
#include<stdio.h>
int main()
{
int (*p)[10];
int arr[10];
int i;
p = arr; /* <-- compiler warning */
for(i=0; i <= 12; i++){ /* i <=12 delibrately written code */
*((*p) + i) = i;
printf("%d\n", p[0]);
}
return 0;
}
In the above program compiler is giving following warning
$gcc pointer2array.c
pointer2array.c: In function `main':
pointer2array.c:8: warning: assignment from incompatible pointer type
Why the warning?
O'kay and what is the use of int (*p)[10] type of declaration ?
Does the compiler perform any check on the array bounds?
lets say if i declare int arr[12]...
-Neo
#include<stdio.h>
int main()
{
int (*p)[10];
int arr[10];
int i;
p = arr; /* <-- compiler warning */
for(i=0; i <= 12; i++){ /* i <=12 delibrately written code */
*((*p) + i) = i;
printf("%d\n", p[0]);
}
return 0;
}
In the above program compiler is giving following warning
$gcc pointer2array.c
pointer2array.c: In function `main':
pointer2array.c:8: warning: assignment from incompatible pointer type
Why the warning?
O'kay and what is the use of int (*p)[10] type of declaration ?
Does the compiler perform any check on the array bounds?
lets say if i declare int arr[12]...
-Neo