O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Beginning C, Fifth Edition

Book Description

Beginning C, 5th Edition teaches you how to program using the widely-available C language. You'll begin from first-principles and progress through step-by-step examples to become a competent, C-language programmer. All you need are this book and any of the widely available free or commercial C or C++ compilers, and you'll soon be writing real C programs.

C is a foundational language that every programmer ought to know. C is the basis for C# used in Microsoft .NET programming. It is the basis for Objective-C used in programming for the iPhone, the iPad, and other Apple devices. It is the basis for the C++ that is widely used in a great many contexts, including the GNU Project. It underlies the Linux operating system and many of its utilities. Learning C provides a strong foundation for any programming care, and will even help you better understand more modern languages such as Java.

Beginning C is written by renowned author Ivor Horton. The book increases your programming expertise by guiding you through the development of fully working C applications that use what you've learned in a practical context. You'll also be able to strike out on your own by trying the exercises included at the end of each chapter. At the end of the book you'll be confident in your skills with all facets of the widely-used and powerful C language.

  • The only beginning-level book to cover the latest ANSI standard in C

  • Revised to cover C99 features newly-supported by language compilers

  • Emphasizes writing code after the first chapter

  • Includes substantial examples relevant to intermediate users

What you'll learn

  • Make use of all core language features such as for loops and branching

  • Dynamically manage memory using pointers and indirection

  • Modularize your code through controlling scope and creating functions

  • Move data in and out of your program via keyboard, display monitor, and data files

  • Have the computer write your code for you via preprocesser directives

  • Properly type your data and create structures to manage it efficiently

Who this book is for

Beginning C, 5th Edition is aimed at programmers aspiring to work with C and C-like languages on platforms ranging from mobile devices such as phones and tablets to desktop environments to server hardware. The book is also helpful to programmers working in the field of embedded software, such as that used to control microwaves, toasters, and other home appliances. Any programmer seeking mastery of possibly the most fundational language in existence will find in Beginning C an excellent, sound, standards-based introduction that will serve them well in their career.

Table of Contents

  1. Title Page
  2. Dedication
  3. Contents at a Glance
  4. Contents
  5. About the Author
  6. About the Technical Reviewer
  7. Acknowledgments
  8. Introduction
  9. CHAPTER 1: Programming in C
    1. The C Language
    2. The Standard Library
    3. Learning C
    4. Creating C Programs
    5. Creating Your First Program
    6. Editing Your First Program
    7. Dealing with Errors
    8. Dissecting a Simple Program
    9. The Preprocessor
    10. Developing Programs in C
    11. Functions and Modular Programming
    12. Common Mistakes
    13. Points to Remember
    14. Summary
  10. CHAPTER 2: First Steps in Programming
    1. Memory in Your Computer
    2. What Is a Variable?
    3. Basic Arithmetic Operations
    4. Variables and Memory
    5. Working with Floating-Point Numbers
    6. More Complicated Expressions
    7. Defining Named Constants
    8. Knowing Your Limitations
    9. Introducing the sizeof Operator
    10. Choosing the Correct Type for the Job
    11. Explicit Type Conversion
    12. More Numeric Data Types
    13. The op= Form of Assignment
    14. Mathematical Functions
    15. Designing a Program
    16. Summary
  11. CHAPTER 3: Making Decisions
    1. The Decision-Making Process
    2. Multiple-Choice Questions
    3. Bitwise Operators
    4. Designing a Program
    5. Summary
  12. CHAPTER 4: Loops
    1. How Loops Work
    2. Introducing the Increment and Decrement Operators
    3. The for Loop
    4. General Form of the for Loop
    5. More on the Increment and Decrement Operators
    6. The for Loop Revisited
    7. The while Loop
    8. Nested Loops
    9. Nested Loops and the goto Statement
    10. The do-while Loop
    11. The continue Statement
    12. Designing a Program
    13. Summary
  13. CHAPTER 5: Arrays
    1. An Introduction to Arrays
    2. The Address of Operator
    3. Arrays and Addresses
    4. Initializing an Array
    5. Finding the Size of an Array
    6. Multidimensional Arrays
    7. Initializing Multidimensional Arrays
    8. Variable Length Arrays
    9. Designing a Program
    10. Summary
  14. CHAPTER 6: Applications with Strings and Text
    1. What Is a String?
    2. Variables That Store Strings
    3. Arrays of Strings
    4. Operations with Strings
    5. Analyzing and Transforming Strings
    6. Designing a Program
    7. Summary
  15. CHAPTER 7: Pointers
    1. A First Look at Pointers
    2. Arrays and Pointers
    3. Multidimensional Arrays
    4. Using Memory As You Go
    5. Handling Strings Using Pointers
    6. Designing a Program
    7. Summary
  16. CHAPTER 8: Structuring Your Programs
    1. Program Structure
    2. Functions
    3. The Pass-By-Value Mechanism
    4. Function Prototypes
    5. Pointers as Parameters and Return Types
    6. Summary
  17. CHAPTER 9: More on Functions
    1. Pointers to Functions
    2. Variables in Functions
    3. Functions That Call Themselves: Recursion
    4. Functions with a Variable Number of Arguments
    5. The main() Function
    6. Terminating a Program
    7. Enhancing Performance
    8. Designing a Program
    9. Summary
  18. CHAPTER 10: Essential Input and Output
    1. Input and Output Streams
    2. Standard Streams
    3. Input from the Keyboard
    4. Output to the Screen
    5. Other Output Functions
    6. Summary
  19. CHAPTER 11: Structuring Data
    1. Data Structures: Using struct
    2. More on Structure Members
    3. Structures and Functions
    4. Sharing Memory
    5. Designing a Program
    6. Summary
  20. CHAPTER 12: Working with Files
    1. The Concept of a File
    2. Accessing Files
    3. Writing a Text File
    4. Reading a Text File
    5. Reading and Writing Strings to a Text File
    6. Formatted File Input and Output
    7. Dealing with Errors
    8. More Open Modes for Text Files
    9. The freopen_s() Function
    10. Binary File Input and Output
    11. Moving Around in a File
    12. Using Temporary Work Files
    13. Updating Binary Files
    14. File Open Modes Summary
    15. Designing a Program
    16. Summary
  21. CHAPTER 13: The Preprocessor and Debugging
    1. Preprocessing
    2. Macros
    3. Preprocessor Directives on Multiple Lines
    4. Debugging Methods
    5. Date and Time Functions
    6. Summary
  22. CHAPTER 14: Advanced and Specialized Topics
    1. Working with International Character Sets
    2. Specialized Integer Types for Portability
    3. The Complex Number Types
    4. Programming with Threads
    5. Summary
  23. APPENDIX A: Computer Arithmetic
    1. Binary Numbers
    2. Hexadecimal Numbers
    3. Negative Binary Numbers
    4. Big-Endian and Little-Endian Systems
    5. Floating-Point Numbers
  24. APPENDIX B: ASCII Character Code Definitions
  25. APPENDIX C: Reserved Words in C
  26. APPENDIX D: Input and Output Format Specifications
    1. Output Format Specifications
    2. Input Format Specifications
  27. APPENDIX E: Standard Library Header Files
  28. Index