ratheesh k wrote:
> int *s_ptr;
> int **d_ptr;
> int arr[2][2]={1,2,3,4};
>
> s_ptr=*arr; /* This is perfectly fine */
> d_ptr=arr /* this line throws a warning: assignment from incompatible
> pointer type */ ????????
Arrays are not pointers. If you use the name of an array as an
expression, it is treated as a pointer to the first element.
For one-dimensional arrays, this means that you can use an array in
most places where a pointer is required. But this doesn't hold for
higher dimensions; an array of pointers isn't the same as an array of
arrays. It also doesn't hold for many other cases, i.e. sizeof,
variable declarations, etc.
--
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Linux Assembler]
[Git]
[Kernel List]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[Yosemite Campsites]
[Yosemite News]
[GCC Help]