|
|
How do I declare a pointer to an array? - C
|
Views : 246
|
|
Tagged in : C
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Usually, you don't want to. Consider using a pointer to one of the array's elements instead. Arrays of type T decay into pointers to type T, which is convenient; subscripting or incrementing the resultant pointer access the individual members of the array. True pointers to arrays, when subscripted or incremented, step over entire arrays, and are generally only useful when operating on multidimensional arrays, if at all. (See question 22 above.) When people speak casually of a pointer to an array, they usually mean a pointer to its first element.
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 66.) If the size of the array is unknown, N can be omitted, but the resulting type, "pointer to array of unknown size," is useless. |
|
By Vijayaprasad, On - 2010-02-16 |
|
|
|