Ch5: Pointers & C‑style Arrays
Overview
This chapter introduces three closely related ideas in C++: pointers, C‑style arrays, and C‑style strings. These appear frequently in existing C and C++ code, libraries, and examples.
Earlier chapters focused on safer containers such as
::fast_io::vector, ::fast_io::string, and
::fast_io::array. In this chapter, you will learn:
- what an address is and how pointers refer to objects
- how C‑style arrays and C‑style strings are represented
- how pointer arithmetic relates to indexing
- how to connect pointers with
::fast_io::vector,::fast_io::array, and::fast_io::string
A major goal is to show how pointers fit naturally into the container model you already know from Chapter 4.
Contents
- Ch5.1: Memory & Addresses
- Ch5.2: Pointer Basics
- Ch5.3: Dereferencing
- Ch5.4: nullptr
- Ch5.5: C‑style Arrays
- Ch5.6: Pointer Arithmetic
- Ch5.7: C-style Array Decay
- Ch5.8: C‑style Strings
- Ch5.9: Multi‑dimensional C‑style Arrays
- Ch5.10: const and Pointers
- Ch5.11: void*
- Ch5.12: Pointers with vector, array, and string
- Ch5.13: Strict Aliasing Rule
- Ch5.14: memfunctions
- Ch5.15: Common Pointer Pitfalls
- Ch5.16: Best Practices