CHAPTER 3

image

Pointers

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.