Modern C

Book description

Modern C introduces you to modern day C programming, emphasizing the unique and new features of this powerful language. For new C coders, it starts with fundamentals like structure, grammar, compilation, and execution. From there, you’ll advance to control structures, data types, operators, and functions, as you gain a deeper understanding of what’s happening under the hood. In the final chapters, you’ll explore performance considerations, reentrancy, atomicity, threads, and type-generic programming. You’ll code as you go with concept-reinforcing exercises and skill-honing challenges along the way.

Table of contents

  1. Copyright
  2. Brief Table of Contents
  3. Table of Contents
  4. Acknowledgments
  5. About this book
  6. About the cover illustration
  7. Level 0. Encounter
    1. Chapter 1. Getting started
      1. 1.1. Imperative programming
      2. 1.2. Compiling and running
      3. Summary
    2. Chapter 2. The principal structure of a program
      1. 2.1. Grammar
      2. 2.2. Declarations
      3. 2.3. Definitions
      4. 2.4. Statements
      5. Summary
      6. Buckle up
  8. Level 1. Acquaintance
    1. Chapter 3. Everything is about control
      1. 3.1. Conditional execution
      2. 3.2. Iterations
      3. 3.3. Multiple selection
      4. Summary
    2. Chapter 4. Expressing computations
      1. 4.1. Arithmetic
      2. 4.2. Operators that modify objects
      3. 4.3. Boolean context
      4. 4.4. The ternary or conditional operator
      5. 4.5. Evaluation order
      6. Summary
    3. Chapter 5. Basic values and data
      1. 5.1. The abstract state machine
      2. 5.2. Basic types
      3. 5.3. Specifying values
      4. 5.4. Implicit conversions
      5. 5.5. Initializers
      6. 5.6. Named constants
      7. 5.7. Binary representions
      8. Summary
    4. Chapter 6. Derived data types
      1. 6.1. Arrays
      2. 6.2. Pointers as opaque types
      3. 6.3. Structures
      4. 6.4. New names for types: type aliases
      5. Summary
    5. Chapter 7. Functions
      1. 7.1. Simple functions
      2. 7.2. main is special
      3. 7.3. Recursion
      4. Summary
    6. Chapter 8. C library functions
      1. 8.1. General properties of the C library and its functions
      2. 8.2. Mathematics
      3. 8.3. Input, output, and file manipulation
      4. 8.4. String processing and conversion
      5. 8.5. Time
      6. 8.6. Runtime environment settings
      7. 8.7. Program termination and assertions
      8. Summary
  9. Level 2. Cognition
    1. Chapter 9. Style
      1. 9.1. Formatting
      2. 9.2. Naming
      3. Summary
    2. Chapter 10. Organization and documentation
      1. 10.1. Interface documentation
      2. 10.2. Implementation
      3. Summary
    3. Chapter 11. Pointers
      1. 11.1. Pointer operations
      2. 11.2. Pointers and structures
      3. 11.3. Pointers and arrays
      4. 11.4. Function pointers
      5. Summary
    4. Chapter 12. The C memory model
      1. 12.1. A uniform memory model
      2. 12.2. Unions
      3. 12.3. Memory and state
      4. 12.4. Pointers to unspecific objects
      5. 12.5. Explicit conversions
      6. 12.6. Effective types
      7. 12.7. Alignment
      8. Summary
    5. Chapter 13. Storage
      1. 13.1. malloc and friends
      2. 13.2. Storage duration, lifetime, and visibility
      3. 13.3. Digression: using objects "before” their definition
      4. 13.4. Initialization
      5. 13.5. Digression: a machine model
      6. Summary
    6. Chapter 14. More involved processing and IO
      1. 14.1. Text processing
      2. 14.2. Formatted input
      3. 14.3. Extended character sets
      4. 14.4. Binary streams
      5. 14.5. Error checking and cleanup
      6. Summary
  10. Level 3. Experience
    1. Chapter 15. Performance
      1. 15.1. Inline functions
      2. 15.2. Using restrict qualifiers
      3. 15.3. Measurement and inspection
      4. Summary
    2. Chapter 16. Function-like macros
      1. 16.1. How function-like macros work
      2. 16.2. Argument checking
      3. 16.3. Accessing the calling context
      4. 16.4. Default arguments
      5. 16.5. Variable-length argument lists
      6. 16.6. Type-generic programming
      7. Summary
    3. Chapter 17. Variations in control flow
      1. 17.1. A complicated example
      2. 17.2. Sequencing
      3. 17.3. Short jumps
      4. 17.4. Functions
      5. 17.5. Long jumps
      6. 17.6. Signal handlers
      7. Summary
    4. Chapter 18. Threads
      1. 18.1. Simple inter-thread control
      2. 18.2. Race-free initialization and destruction
      3. 18.3. Thread-local data
      4. 18.4. Critical data and critical sections
      5. 18.5. Communicating through condition variables
      6. 18.6. More sophisticated thread management
      7. Summary
    5. Chapter 19. Atomic access and memory consistency
      1. 19.1. The “happened before” relation
      2. 19.2. C library calls that provide synchronization
      3. 19.3. Sequential consistency
      4. 19.4. Other consistency models
      5. Summary
  11. Takeaways
  12. Bibliography
  13. Index
  14. List of Figures
  15. List of Tables
  16. List of Listings

Product information

  • Title: Modern C
  • Author(s): Jens Gustedt
  • Release date: December 2019
  • Publisher(s): Manning Publications
  • ISBN: 9781617295812