You are previewing C Programming in One Hour a Day, Sams Teach Yourself, Seventh Edition.
O'Reilly logo
C Programming in One Hour a Day, Sams Teach Yourself, Seventh Edition

Book Description

Sams Teach Yourself C Programming in One Hour a Day, Seventh Edition is the newest version of the worldwide best-seller Sams Teach Yourself C in 21 Days. Fully revised for the new C11 standard and libraries, it now emphasizes platform-independent C programming using free, open-source C compilers. This edition strengthens its focus on C programming fundamentals, and adds new material on popular C-based object-oriented programming languages such as Objective-C.

Filled with carefully explained code, clear syntax examples, and well-crafted exercises, this is the broadest and deepest introductory C tutorial available. It’s ideal for anyone who’s serious about truly mastering C – including thousands of developers who want to leverage its speed and performance in modern mobile and gaming apps.

Friendly and accessible, it delivers step-by-step, hands-on experience that starts with simple tasks and gradually builds to professional-quality techniques. Each lesson is designed to be completed in hour or less, introducing and clearly explaining essential concepts, providing practical examples, and encouraging you to build simple programs on your own. Coverage includes:

  • Understanding C program components and structure

  • Mastering essential C syntax and program control

  • Using core language features, including numeric arrays, pointers, characters, strings, structures, and variable scope

  • Interacting with the screen, printer, and keyboard

  • Using functions and exploring the C Function Library

  • Working with memory and the compiler

  • Contents at a Glance

    PART I: FUNDAMENTALS OF C
    1 Getting Started with C
    2 The Components of a C Program
    3 Storing Information: Variables and Constants
    4 The Pieces of a C Program: Statements, Expressions, and Operators
    5 Packaging Code in Functions
    6 Basic Program Control
    7 Fundamentals of Reading and Writing Information

    PART II: PUTTING C TO WORK
    8 Using Numeric Arrays
    9 Understanding Pointers
    10 Working with Characters and Strings
    11 Implementing Structures, Unions, and TypeDefs
    12 Understanding Variable Scope
    13 Advanced Program Control
    14 Working with the Screen, Printer, and Keyboard

    PART III: ADVANCED C
    15 Pointers to Pointers and Arrays of Pointers
    16 Pointers to Functions and Linked Lists
    17 Using Disk Files
    18 Manipulating Strings
    19 Getting More from Functions
    20 Exploring the C Function Library
    21 Working with Memory
    22 Advanced Compiler Use

    PART IV: APPENDIXES

    A ASCII Chart
    B C/C++ Reserved Words
    C Common C Functions
    D Answers

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. About the Authors
    7. Acknowledgments
    8. We Want to Hear from You!
    9. Reader Services
    10. Introduction
      1. This Book’s Special Features
      2. Syntax
      3. Conventions Used in This Book
    11. Part I: Fundamentals of C
      1. Lesson 1. Getting Started with C
        1. A Brief History of the C Language
        2. Why Use C?
        3. Preparing to Program
        4. The Program Development Cycle
        5. Your First C Program
        6. Summary
        7. Q&A
        8. Workshop
      2. Lesson 2. The Components of a C Program
        1. A Short C Program
        2. The Program’s Components
        3. A Review of the Parts of a Program
        4. Summary
        5. Q&A
        6. Workshop
      3. Lesson 3. Storing Information: Variables and Constants
        1. Understanding Your Computer’s Memory
        2. Storing Information with Variables
        3. Numeric Variable Types
        4. Constants
        5. Summary
        6. Q&A
        7. Workshop
      4. Lesson 4. The Pieces of a C Program: Statements, Expressions, and Operators
        1. Statements
        2. Understanding Expressions
        3. Operators
        4. The if Statement
        5. Evaluating Relational Expressions
        6. The Logical Operators
        7. More on True/False Values
        8. Operator Precedence Revisited
        9. Summary
        10. Q&A
        11. Workshop
      5. Lesson 5. Packaging Code in Functions
        1. Understanding Functions
        2. How a Function Works
        3. Syntax
        4. Functions and Structured Programming
        5. Writing a Function
        6. Passing Arguments to a Function
        7. Calling Functions
        8. Where the Functions Belong
        9. Working with Inline Functions
        10. Summary
        11. Q&A
        12. Workshop
      6. Lesson 6. Basic Program Control
        1. Arrays: The Basics
        2. Controlling Program Execution
        3. Syntax
        4. Syntax
        5. Syntax
        6. Nested Loops
        7. Summary
        8. Q&A
        9. Workshop
      7. Lesson 7. Fundamentals of Reading and Writing Information
        1. Displaying Information Onscreen
        2. Syntax
        3. Syntax
        4. Inputting Numeric Data with scanf()
        5. Syntax
        6. Using Trigraph Sequences
        7. Summary
        8. Q&A
        9. Workshop
    12. Part II: Putting C to Work
      1. Lesson 8. Using Numeric Arrays
        1. What Is an Array?
        2. Naming and Declaring Arrays
        3. Summary
        4. Q&A
        5. Workshop
      2. Lesson 9. Understanding Pointers
        1. What Is a Pointer?
        2. Pointers and Simple Variables
        3. Pointers and Variable Types
        4. Pointers and Arrays
        5. Pointer Cautions
        6. Array Subscript Notation and Pointers
        7. Passing Arrays to Functions
        8. Summary
        9. Q&A
        10. Workshop
      3. Lesson 10. Working with Characters and Strings
        1. The char Data Type
        2. Using Character Variables
        3. Using Strings
        4. Strings and Pointers
        5. Strings Without Arrays
        6. Syntax
        7. Displaying Strings and Characters
        8. Reading Strings from the Keyboard
        9. Syntax
        10. Summary
        11. Q&A
        12. Workshop
      4. Lesson 11. Implementing Structures, Unions, and TypeDefs
        1. Working with Simple Structures
        2. Syntax
        3. Using Structures That Are More Complex
        4. Arrays of Structures
        5. Initializing Structures
        6. Structures and Pointers
        7. Understanding Unions
        8. Syntax
        9. Creating Synonyms for Structures with typedef
        10. Summary
        11. Q&A
        12. Workshop
      5. Lesson 12. Understanding Variable Scope
        1. What Is Scope?
        2. Creating External Variables
        3. Creating Local Variables
        4. Local Variables and the main() Function
        5. Which Storage Class Should You Use?
        6. Local Variables and Blocks
        7. Summary
        8. Q&A
        9. Workshop
      6. Lesson 13. Advanced Program Control
        1. Ending Loops Early
        2. Syntax
        3. Syntax
        4. The goto Statement
        5. Syntax
        6. Infinite Loops
        7. The switch Statement
        8. Syntax
        9. Exiting the Program
        10. Summary
        11. Q&A
        12. Workshop
      7. Lesson 14. Working with the Screen, Printer, and Keyboard
        1. Streams and C
        2. Using C’s Stream Functions
        3. Accepting Keyboard Input
        4. Controlling Output to the Screen
        5. When to Use fprintf()
        6. Summary
        7. Q&A
        8. Workshop
    13. Part III: Advanced C
      1. Lesson 15. Pointers to Pointers and Arrays of Pointers
        1. Declaring Pointers to Pointers
        2. Pointers and Multidimensional Arrays
        3. Working with Arrays of Pointers
        4. Summary
        5. Q&A
        6. Workshop
      2. Lesson 16. Pointers to Functions and Linked Lists
        1. Working with Pointers to Functions
        2. Understanding Linked Lists
        3. Summary
        4. Q&A
        5. Workshop
      3. Lesson 17. Using Disk Files
        1. Relating Streams to Disk Files
        2. Understanding the Types of Disk Files
        3. Using Filenames
        4. Opening a File
        5. Writing and Reading File Data
        6. File Buffering: Closing and Flushing Files
        7. Understanding Sequential Versus Random File Access
        8. Detecting the End of a File
        9. File Management Functions
        10. Using Temporary Files
        11. Summary
        12. Q&A
        13. Workshop
      4. Lesson 18. Manipulating Strings
        1. Determining String Length
        2. Copying Strings
        3. Concatenating Strings
        4. Comparing Strings
        5. Searching Strings
        6. String-to-Number Conversions
        7. Character-Test Functions
        8. Summary
        9. Q&A
        10. Workshop
      5. Lesson 19. Getting More from Functions
        1. Passing Pointers to Functions
        2. Type void Pointers
        3. Using Functions That Have a Variable Number of Arguments
        4. Functions That Return a Pointer
        5. Summary
        6. Q&A
        7. Workshop
      6. Lesson 20. Exploring the C Function Library
        1. Mathematical Functions
        2. Dealing with Time
        3. Error-Handling
        4. Searching and Sorting
        5. Summary
        6. Q&A
        7. Workshop
      7. Lesson 21. Working with Memory
        1. Type Conversions
        2. Allocating Memory Storage Space
        3. Manipulating Memory Blocks
        4. Working with Bits
        5. Summary
        6. Q&A
        7. Workshop
      8. Lesson 22. Advanced Compiler Use
        1. Programming with Multiple Source-Code Files
        2. The C Preprocessor
        3. Predefined Macros
        4. Using Command-Line Arguments
        5. Summary
        6. Q&A
        7. Workshop
    14. Part IV: Appendixes
      1. Appendix A. ASCII Chart
      2. Appendix B. C/C++ Reserved Words
      3. Appendix C. Common C Functions
      4. Appendix D. Answers
        1. Answers for Lesson 1
        2. Answers for Lesson 2
        3. Answers for Lesson 3
        4. Answers for Lesson 4
        5. Answers for Lesson 5
        6. Answers for Lesson 6
        7. Answers for Lesson 7
        8. Answers for Lesson 8
        9. Answers for Lesson 9
        10. Answers for Lesson 10
        11. Answers for Lesson 11
        12. Answers for Lesson 12
        13. Answers for Lesson 13
        14. Answers for Lesson 14
        15. Answers for Lesson 15
        16. Answers for Lesson 16
        17. Answers for Lesson 17
        18. Answers for Lesson 18
        19. Answers for Lesson 19
        20. Answers for Lesson 20
        21. Answers for Lesson 21
        22. Answers for Lesson 22
    15. Index