[prev] [index] [next]

Arrays and Pointers (cont)

On the previous slide, we suggested   s == &s[0]

Types:   s is char[],   &s[0] is char *

There is a close relationship between pointers and arrays

  • an array's name is like a constant pointer to the first element
  • using an unindexed array name gives you the address of the array
Some consequences of this relationship:
  • pointers are often used to reference array elements
  • arrays are passed to functions by reference