Chapter 22. Bits, Characters, C-Strings and structs
The same old charitable lie
Repeated as the years scoot by
Perpetually makes a hit
"You really haven't changed a bit!"
The chief defect of Henry King
Was chewing little bits of string.
Vigorous writing is concise.
A sentence should contain no unnecessary words, a paragraph no unnecessary sentences.
William Strunk, Jr.
In this chapter you will learn:
To create and use structs.
To pass structs to functions by value and by reference.
To use typedef to create aliases for previously defined data types and structs.
To manipulate data with the bitwise operators and to create bit fields for storing data compactly.
To use the functions of the character-handling library <cctype>.
To use the string-conversion functions of the general-utilities library <cstdlib>.
To use the string-processing functions of the string-handling library <cstring>.
22.2 Structure Definitions
22.3 Initializing Structures
22.4 Using Structures with Functions
22.6 Example: High-Performance Card Shuffling and Dealing Simulation
22.7 Bitwise Operators
22.8 Bit Fields
22.9 Character-Handling Library
22.10 Pointer-Based String-Conversion Functions
22.11 Search Functions of the Pointer-Based String-Handling Library
22.12 Memory Functions of the Pointer-Based String-Handling Library
Answers to Self-Review Exercises