Relationship between C Pointers and Arrays

Relationship between Arrays and Pointers

  • &x[0] is the same as x because the variable name ‘x’ points to the first element of the array
  • &x[1] is equivalent to x+1 and x[1] is equivalent to *(x+1).
  • &x[2] is equivalent to x+2 and x[2] is equivalent to *(x+2).
  • Basically, &x[i] is equivalent to x+i and x[i] is equivalent to *(x+i).
  • Array names decay to pointers, which means all array names are converted to pointers.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store