In this chapter, we will explain the following:

  • What a pointer is
  • How to declare pointer variables
  • How to dereference a pointer
  • How a function can change the value of a variable in a “calling” function
  • Some issues involved in passing an array as an argument to a function
  • How to work with character pointers
  • The meaning of pointer arithmetic
  • How to use pointers to structures
  • How to use pointers to functions to write general-purpose routines
  • What are void pointers and how to use them

3.1 Defining Pointers

In C, arguments to functions are passed “by value.” Suppose the function test is called with the variable num as an argument. ...

Get Advanced Topics in C: Core Concepts in Data Structures now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.