Book description
Improve your programming through a solid understanding of C pointers and memory management. With this practical book, you’ll learn how pointers provide the mechanism to dynamically manipulate memory, enhance support for data structures, and enable access to hardware. Author Richard Reese shows you how to use pointers with arrays, strings, structures, and functions, using memory models throughout the book.
Difficult to master, pointers provide C with much flexibility and power—yet few resources are dedicated to this data type. This comprehensive book has the information you need, whether you’re a beginner or an experienced C or C++ programmer or developer.
- Get an introduction to pointers, including the declaration of different pointer types
- Learn about dynamic memory allocation, de-allocation, and alternative memory management techniques
- Use techniques for passing or returning data to and from functions
- Understand the fundamental aspects of arrays as they relate to pointers
- Explore the basics of strings and how pointers are used to support them
- Examine why pointers can be the source of security problems, such as buffer overflow
- Learn several pointer techniques, such as the use of opaque pointers, bounded pointers and, the restrict keyword
Publisher resources
Table of contents
- Preface
-
1. Introduction
- Pointers and Memory
- Pointer Size and Types
- Pointer Operators
- Common Uses of Pointers
- Summary
- 2. Dynamic Memory Management in C
- 3. Pointers and Functions
-
4. Pointers and Arrays
- Quick Review of Arrays
- Pointer Notation and Arrays
- Using malloc to Create a One-Dimensional Array
- Using the realloc Function to Resize an Array
- Passing a One-Dimensional Array
- Using a One-Dimensional Array of Pointers
- Pointers and Multidimensional Arrays
- Passing a Multidimensional Array
- Dynamically Allocating a Two-Dimensional Array
- Jagged Arrays and Pointers
- Summary
- 5. Pointers and Strings
- 6. Pointers and Structures
-
7. Security Issues and the Improper Use of Pointers
- Pointer Declaration and Initialization
-
Pointer Usage Issues
- Test for NULL
- Misuse of the Dereference Operator
- Dangling Pointers
- Accessing Memory Outside the Bounds of an Array
- Calculating the Array Size Incorrectly
- Misusing the sizeof Operator
- Always Match Pointer Types
- Bounded Pointers
- String Security Issues
- Pointer Arithmetic and Structures
- Function Pointer Issues
- Memory Deallocation Issues
- Using Static Analysis Tools
- Summary
- 8. Odds and Ends
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Understanding and Using C Pointers
- Author(s):
- Release date: May 2013
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449344184
You might also like
book
Engineering a Compiler
This entirely revised second edition of Engineering a Compiler is full of technical updates and new …
book
Building Microservices, 2nd Edition
As organizations shift from monolithic applications to smaller, self-contained microservices, distributed systems have become more fine-grained. …
book
Clean Code: A Handbook of Agile Software Craftsmanship
Even bad code can function. But if code isn’t clean, it can bring a development organization …
book
Head First Git
What will you learn from this book? Many people who use Git rely on "recipes"--copying and …