Summary

  • A pointer is a variable that contains the address of another variable.
  • The unary operator '&, also called the address operator, obtains the address of a variable when applied to it.
  • The unary operator. also called the indirection or dereferencing operator, gives the value of what a pointer is pointing to.
  • It is always good practice to initialize pointers as soon as they are declared.
  • Complicated manipulation of pointers is possible through the use of the unary operators '&' and '*".
  • There is a strong relationship between pointers and arrays.
  • The main difference between a pointer and an array is that., when declared, memory (the apecified number of bytes) is definitely set aside for an array, whereas in the case of a pointer. it is not.
  • Whenever a pointer is incremented by one, the result is computed as

New address = old address + size of datatype

  • Size of datatype is 1 for character, 4 for integer (this value may vary from system to

system), 4 for float values, and 8 for double.

Review Questions

  1. An uninitialized pointer. when used in a program, can cause it to crash. Explain with examples.
  2. What will be the output of the following piece of code
int x[5][3] = {
{2, 3, 5, 6, 7},
{1, 4, 8, 9, 10},
{11, 12, 13, 14, 15}
 };
int *xptr;
xptr = &x;
printf("%d", *xptr);
printf("%d", *(*xptr+1))​