[prev] 57 [next]

Pointers (cont)

Code and data is aligned and is machine dependant. For example:
  • char ... can be stored at any byte address
  • int ... must be stored at an address  addr %4 == 0
  • double ... often must be stored at an address  addr %8 == 0
Thus pointer values must be appropriate for data type, e.g.
  • (char *) ... can reference any byte address
  • (int *) ... must have  addr %4 == 0
  • (double *) ... might need to have  addr %8 == 0