2009-03-30

C pointers

clipped from wps.prenhall.com
  • Pointers are variables that contain as their values addresses of other variables.
  • Pointers must be defined before they can be used.
  • The definition

    int *ptr;

  • defines ptr to be a pointer to an object of type int and is read, "ptr is a pointer to int." The * as used here indicates that the variable is a pointer.

  • There are three values that can be used to initialize a pointer; 0, NULL, or an address. Initializing a pointer to 0 and initializing that same pointer to NULL are identical.
  • The only integer that can be assigned to a pointer is 0.
  • The & (address) operator returns the address of its operand.
  • The * operator, referred to as the indirection or dereferencing operator, returns the value of the object that its operand points to in memory. This is called dereferencing the pointer.
  •  blog it

    沒有留言: