Seo Forum

Coding & Programming => Programming Forum => Topic started by: beingchinmay on 09-27-2016, 06:20:03

Title: Are Pointers and Arrays Interchangeable?
Post by: beingchinmay on 09-27-2016, 06:20:03
As the preceding few pages have shown, pointers and arrays are strongly related. In fact, pointers and arrays are interchangeable in many cases. For example, a pointer that points to the beginning of an array can access that array by using either pointer arithmetic or array-style indexing. However, pointers and arrays are not completely interchangeable. For example, consider this fragment:

Code:
Only registered users can see contents. Please click here to Register or Login.]
'
Here, num is an array of integers. As the comments describe, while it is perfectly acceptable to apply the * operator to num (which is a pointer operation), it is illegal to modify num’s value. The reason for this is that num is a constant that points to the beginning of an array. Thus, you cannot increment it. More generally, while an array name without an index does generate a pointer to the beginning of an array, it cannot be changed.