B
blue
Hi, all:
Recently I found this comment on comp.lang.c "Answers to FAQ" (6.13):
If you really need to declare a pointer to an entire array, use
something like "int (*ap)[N];" where N is the size of the array. (See
also question 1.21.) If the size of the array is unknown, N can in
principle be omitted, but the resulting type, "pointer to array of
unknown size," is useless.
However, when I try to write a sample program like:
int main()
{
int (*arrptr)[5];
int arr[5] = {1,2,3,4,5};
arrptr = arr;
printf( "%d", arrptr[0] );
}
Why could it not work? Besides, does anyone know the real usage of
array pointers?
Best regards,
blue
Recently I found this comment on comp.lang.c "Answers to FAQ" (6.13):
If you really need to declare a pointer to an entire array, use
something like "int (*ap)[N];" where N is the size of the array. (See
also question 1.21.) If the size of the array is unknown, N can in
principle be omitted, but the resulting type, "pointer to array of
unknown size," is useless.
However, when I try to write a sample program like:
int main()
{
int (*arrptr)[5];
int arr[5] = {1,2,3,4,5};
arrptr = arr;
printf( "%d", arrptr[0] );
}
Why could it not work? Besides, does anyone know the real usage of
array pointers?
Best regards,
blue