C Primer Plus®, Third Edition

Book description

The Waite Group's C Primer Plus, Third edition, presents the ANSI C standard beginning with a discussion of the fundamentals of C programming and then continues on to illustrate real-world C programming concepts and techniques. The Waite Group's C Primer Plus, Third Edition, is jam-packed with hundreds of sample programs, challenging yet humorous examples, hints and quizzes. Get the latest information on migrating from C to C++ and find out what will change with the release of the new C ANSI/ISO standard. Learn the mechanics of C programming and how to create programs that are easy to read, debug and update using real-world, easy-to-follow examples.

Table of contents

  1. Copyright
  2. Preface
  3. About the Author
  4. Acknowledgments
  5. Tell Us What You Think!
  6. Getting Ready
    1. Whence C?
    2. Why C?
    3. Whither C?
    4. Using C: Seven Steps
    5. Programming Mechanics
    6. Language Standards
    7. Some Conventions
    8. Chapter Summary
    9. Review Questions
    10. Programming Exercise
  7. Introducing C
    1. A Simple Sample of C
    2. The Explanation
    3. The Structure of a Simple Program
    4. Tips on Making Your Programs Readable
    5. Taking Another Step
    6. While You're at It…Multiple Functions
    7. Debugging
    8. Keywords
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  8. Data and C
    1. A Sample Program
    2. Data Variables and Constants
    3. Data: Data-Type Keywords
    4. C Data Types
    5. Using Data Types
    6. Arguments and Pitfalls
    7. One More Example
    8. Chapter Summary
    9. Review Questions
    10. Programming Exercises
  9. Character Strings and Formatted Input/Output
    1. Introductory Program
    2. Character Strings: An Introduction
    3. Constants and the C Preprocessor
    4. Exploring and Exploiting printf() and scanf()
    5. Usage Tips
    6. Chapter Summary
    7. Review Questions
    8. Programming Exercises
  10. Operators, Expressions, and Statements
    1. Introducing Loops
    2. Fundamental Operators
    3. Some Additional Operators
    4. Expressions and Statements
    5. Type Conversions
    6. Function with Arguments
    7. A Sample Program
    8. Chapter Summary
    9. Review Questions
    10. Programming Exercises
  11. C Control Statements: Looping
    1. An Initial Example
    2. The while Statement
    3. Which Is Bigger: Using Relational Operators and Expressions
    4. Indefinite Loops and Counting Loops
    5. The for Loop
    6. More Assignment Operators: +=, −=, *=, /=, %=
    7. The Comma Operator
    8. An Exit-Condition Loop: do while
    9. Which Loop?
    10. Nested Loops
    11. Arrays
    12. A Loop Example Using a Function Return Value
    13. Chapter Summary
    14. Review Questions
    15. Programming Exercises
  12. C Control Statements: Branching and Jumps
    1. The if Statement
    2. Adding else to the if Statement
    3. Let's Get Logical
    4. A Word-Count Program
    5. The Conditional Operator: ?
    6. Loop Aids: continue and break
    7. Multiple Choice: switch and break
    8. The goto Statement
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  13. Character Input/Output and Redirection
    1. Single-Character I/O:getchar() and putchar()
    2. Buffers
    3. Terminating Keyboard Input
    4. Redirection and Files
    5. A Graphic Example
    6. Creating a Friendlier User Interface
    7. Character Sketches
    8. Menu Browsing
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  14. Functions
    1. Review
    2. ANSI C Function Prototyping
    3. Recursion
    4. All C Functions Are Created Equal
    5. Compiling Programs with Two or More Functions
    6. Finding Addresses: The & Operator
    7. Altering Variables in the Calling Function
    8. Pointers: A First Look
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  15. Arrays and Pointers
    1. Arrays
    2. Pointers to Arrays
    3. Functions, Arrays, and Pointers
    4. Pointer Operations
    5. Protecting Array Contents
    6. Multidimensional Arrays
    7. Pointers and Multidimensional Arrays
    8. Planning a Program
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  16. Character Strings and String Functions
    1. Defining Strings Within a Program
    2. Character String Arrays and Initialization
    3. String Input
    4. String Output
    5. The Do-It-Yourself Option
    6. String Functions
    7. A String Example: Sorting Strings
    8. The ctype.h Character Functions and Strings
    9. Command-Line Arguments
    10. String to Number Conversions
    11. Chapter Summary
    12. Review Questions
    13. Programming Exercises
  17. File Input/Output
    1. Communicating with Files
    2. Standard I/O
    3. A Simple-Minded File-Condensing Program
    4. File I/O: fprintf(), fscanf(), fgets(), and fputs()
    5. Adventures in Random Access: fseek() and ftell()
    6. Behind the Scenes with Standard I/O
    7. Other Standard I/O Functions
    8. Chapter Summary
    9. Review Questions
    10. Programming Exercises
  18. Storage Classes and Program Development
    1. Storage Classes and Scope
    2. A Random Number Function
    3. Roll 'Em
    4. Sorting Numbers
    5. ANSI C Type Qualifiers
    6. Chapter Summary
    7. Review Questions
    8. Programming Exercises
  19. Structures and Other Data Forms
    1. Sample Problem: Creating an Inventory of Books
    2. Setting Up the Structure Declaration
    3. Defining a Structure Variable
    4. Gaining Access to Structure Members
    5. Arrays of Structures
    6. Nested Structures
    7. Pointers to Structures
    8. Telling Functions About Structures
    9. Saving the Structure Contents in a File
    10. Structures: What Next?
    11. Unions: A Quick Look
    12. typedef: A Quick Look
    13. Fancy Declarations
    14. Functions and Pointers
    15. Chapter Summary
    16. Review Questions
    17. Programming Exercises
  20. Bit Fiddling
    1. Binary Numbers, Bits, and Bytes
    2. Other Bases
    3. C's Bitwise Operators
    4. Bit Fields
    5. Chapter Summary
    6. Review Questions
    7. Programming Exercises
  21. The C Preprocessor and the C Library
    1. Manifest Constants: #define
    2. Using Arguments with #define
    3. Macro or Function?
    4. File Inclusion: #include
    5. Other Directives
    6. Enumerated Types
    7. The C Library
    8. The Math Library
    9. The General Utilities Library
    10. The Assert Library
    11. Chapter Summary
    12. Review Questions
    13. Programming Exercises
  22. Advanced Data Representation
    1. Exploring Data Representation
    2. Beyond the Array to the Linked List
    3. Abstract Data Types (ADTs)
    4. Getting Queued with an ADT
    5. Simulating with a Queue
    6. The Linked List Versus the Array
    7. Binary Search Trees
    8. Other Directions
    9. Chapter Summary
    10. Review Questions
    11. Programming Exercises
  23. Additional Reading
    1. C Language
    2. Programming
    3. Reference
  24. C Operators
    1. Arithmetic Operators
    2. Relational Operators
    3. Assignment Operators
    4. Logical Operators
    5. The Conditional Operator
    6. Pointer-Related Operators
    7. Sign Operators
    8. Structure and Union Operators
    9. Bitwise Operators
    10. Miscellaneous Operators
  25. Basic Types and Storage Classes
    1. Summary: The Basic Data Types
    2. Summary: How to Declare a Simple Variable
    3. Summary: Qualifiers
  26. Expressions, Statements, and Program Flow
    1. Summary: Expressions and Statements
    2. Summary: The while Statement
    3. Summary: The for Statement
    4. Summary: The do while Statement
    5. Summary: Using if Statements for Making Choices
    6. Summary: Multiple Choice with switch
    7. Summary: Program Jumps
  27. The ASCII Character Set
  28. The Standard ANSI C Library
    1. Diagnostics: assert.h
    2. Character Handling: ctype.h
    3. Localization: locale.h
    4. Math Library: math.h
    5. Non-Local Jumps: setjmp.h
    6. Signal Handling: signal.h
    7. Variable Arguments: stdarg.h
    8. Standard I/O Library: stdio.h
    9. General Utilities: stdlib.h
    10. String Handling: string.h
    11. Date and Time: time.h
  29. Differences Between C and C++
    1. Declarations
    2. Function Prototypes
    3. Function Definitions
    4. Comments
    5. char Constants
    6. The const Modifier
    7. Structures and Unions
    8. Enumerations
    9. Pointer Type-Checking
  30. The C9X Committee
    1. Types
    2. Enhanced Computational Support
    3. Wide Character Support
  31. Answers to the Review Questions
    1. Chapter 1
    2. Chapter 2
    3. Chapter 3
    4. Chapter 4
    5. Chapter 5
    6. Chapter 6
    7. Chapter 7
    8. Chapter 8
    9. Chapter 9
    10. Chapter 10
    11. Chapter 11
    12. Chapter 12
    13. Chapter 13
    14. Chapter 14
    15. Chapter 15
    16. Chapter 16
    17. Chapter 17
  32. Index

Product information

  • Title: C Primer Plus®, Third Edition
  • Author(s): Stephen Prata
  • Release date: September 1998
  • Publisher(s): Sams
  • ISBN: 9781571691613