Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • So it seems to me that the square brackets always implicitly dereference the pointer just as they implicitly define a double pointer (as you pointed out). Therefore, anytime I have a pointer that points to an array of ints I never have to dereference the pointer object to get at the array so long as square brackets follow? Commented Jun 9, 2022 at 12:56
  • 1
    @hijit An expression like this p[i] where p is a pointer or an array is evaluated like *( p + i ). In case when p is an array then it is implicitly converted to a pointer to its first element. If you have for example int a[] = { 1, 2, 3 }; int *p = a; then the both expressions *p and *a are equivalent to p[0] and a[0]. Commented Jun 9, 2022 at 13:00
  • great, thanks for the explanation, that clarifies things nicely. Commented Jun 9, 2022 at 13:14