Skip to main content

Introduction

Pointers are variables that store an address. They are a fundamental mechanism in C that enable pass by address, allowing functions to work with the original variables rather than copies. Pointers are an efficient way to pass complex types into a function as we are only passing in their location. Aside from efficiency, pointers also allow a function to provide multiple results.

Learning Outcomes

After completing this chapter, students will be able to:

  1. Explain pointer related concepts by defining the relationships between pointers, variables and memory.
  2. Declare pointer variables using proper C syntax and understand that pointers store memory addresses of other variables
  3. Understand pass by value vs. pass by address and explain why pass by address is more efficient when passing structs to functions
  4. Pass structs to functions by address using the & operator and recognize how this avoids duplicating struct data
  5. Access struct data members through pointers using the -> operator and explain how it differs from the . operator
  6. Use pointers to pass back multiple results from a function by dereferencing pointers with the * operator to modify variables in the calling function
  7. Distinguish between the address-of operator and dereference operator and apply each correctly in different contexts