C Programming Absolute Beginner’s Guide, Third Edition

Book description

Updated for C11

Write powerful C programs…without becoming a technical expert! This book is the fastest way to get comfortable with C, one incredibly clear and easy step at a time. You’ll learn all the basics: how to organize programs, store and display data, work with variables, operators, I/O, pointers, arrays, functions, and much more. C programming has neverbeen this simple!

Who knew how simple C programming could be?

This is today’s best beginner’s guide to writing C programs–and to learning skills you can use with practically any language. Its simple, practical instructions will help you start creating useful, reliable C code, from games to mobile apps. Plus, it’s fully updated for the new C11 standard and today’s free, open source tools! Here’s a small sample of what you’ll learn:

• Discover free C programming tools for Windows, OS X, or Linux

• Understand the parts of a C program and how they fit together

• Generate output and display it on the screen

• Interact with users and respond to their input

• Make the most of variables by using assignments and expressions

• Control programs by testing data and using logical operators

• Save time and effort by using loops and other techniques

• Build powerful data-entry routines with simple built-in functions

• Manipulate text with strings

• Store information, so it’s easy to access and use

• Manage your data with arrays, pointers, and data structures

• Use functions to make programs easier to write and maintain

• Let C handle all your program’s math for you

• Handle your computer’s memory as efficiently as possible

• Make programs more powerful with preprocessing directives

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. Dedication
  8. Acknowledgments
  9. We Want to Hear from You!
  10. Reader Services
  11. Introduction
    1. Who’s This Book For?
    2. What Makes This Book Different?
    3. This Book’s Design Elements
    4. How Can I Have Fun with C?
    5. What Do I Do Now?
  12. Part I: Jumping Right In
    1. 1. What Is C Programming, and Why Should I Care?
      1. What Is a Program?
      2. What You Need to Write C Programs
      3. The Programming Process
      4. Using C
    2. 2. Writing Your First C Program
      1. A Down-and-Dirty Chunk of Code
      2. The main() Function
      3. Kinds of Data
      4. Wrapping Things Up with Another Example Program
    3. 3. What Does This Do? Clarifying Your Code with Comments
      1. Commenting on Your Code
      2. Specifying Comments
      3. Whitespace
      4. A Second Style for Your Comments
    4. 4. Your World Premiere—Putting Your Program’s Results Up on the Screen
      1. How to Use printf()
      2. Printing Strings
      3. Escape Sequences
      4. Conversion Characters
      5. Putting It All Together with a Code Example
    5. 5. Adding Variables to Your Programs
      1. Kinds of Variables
      2. Naming Variables
      3. Defining Variables
      4. Storing Data in Variables
    6. 6. Adding Words to Your Programs
      1. Understanding the String Terminator
      2. The Length of Strings
      3. Character Arrays: Lists of Characters
      4. Initializing Strings
    7. 7. Making Your Programs More Powerful with #include and #define
      1. Including Files
      2. Placing #include Directives
      3. Defining Constants
      4. Building a Header File and Program
    8. 8. Interacting with Users
      1. Looking at scanf()
      2. Prompting for scanf()
      3. Problems with scanf()
  13. Part II: Putting C to Work for You with Operators and Expressions
    1. 9. Crunching the Numbers—Letting C Handle Math for You
      1. Basic Arithmetic
      2. Order of Operators
      3. Break the Rules with Parentheses
      4. Assignments Everywhere
    2. 10. Powering Up Your Variables with Assignments and Expressions
      1. Compound Assignment
      2. Watch That Order!
      3. Typecasting: Hollywood Could Take Lessons from C
    3. 11. The Fork in the Road—Testing Data to Pick a Path
      1. Testing Data
      2. Using if
      3. Otherwise...: Using else
    4. 12. Juggling Several Choices with Logical Operators
      1. Getting Logical
      2. Avoiding the Negative
      3. The Order of Logical Operators
    5. 13. A Bigger Bag of Tricks—Some More Operators for Your Programs
      1. Goodbye if...else; Hello, Conditional
      2. The Small-Change Operators: ++ and --
      3. Sizing Up the Situation
  14. Part III: Fleshing Out Your Programs
    1. 14. Code Repeat—Using Loops to Save Time and Effort
      1. while We Repeat
      2. Using while
      3. Using do...while
    2. 15. Looking for Another Way to Create Loops
      1. for Repeat’s Sake!
      2. Working with for
    3. 16. Breaking in and out of Looped Code
      1. Take a break
      2. Let’s continue Working
    4. 17. Making the case for the switch Statement
      1. Making the switch
      2. break and switch
      3. Efficiency Considerations
    5. 18. Increasing Your Program’s Output (and Input)
      1. putchar() and getchar()
      2. The Newline Consideration
      3. A Little Faster: getch()
    6. 19. Getting More from Your Strings
      1. Character-Testing Functions
      2. Is the Case Correct?
      3. Case-Changing Functions
      4. String Functions
    7. 20. Advanced Math (for the Computer, Not You!)
      1. Practicing Your Math
      2. Doing More Conversions
      3. Getting into Trig and Other Really Hard Stuff
      4. Getting Random
  15. Part IV: Managing Data with Your C Programs
    1. 21. Dealing with Arrays
      1. Reviewing Arrays
      2. Putting Values in Arrays
    2. 22. Searching Arrays
      1. Filling Arrays
      2. Finders, Keepers
    3. 23. Alphabetizing and Arranging Your Data
      1. Putting Your House in Order: Sorting
      2. Faster Searches
    4. 24. Solving the Mystery of Pointers
      1. Memory Addresses
      2. Defining Pointer Variables
      3. Using the Dereferencing *
    5. 25. Arrays and Pointers
      1. Array Names Are Pointers
      2. Getting Down in the List
      3. Characters and Pointers
      4. Be Careful with Lengths
      5. Arrays of Pointers
    6. 26. Maximizing Your Computer’s Memory
      1. Thinking of the Heap
      2. But Why Do I Need the Heap?
      3. How Do I Allocate the Heap?
      4. If There’s Not Enough Heap Memory
      5. Freeing Heap Memory
      6. Multiple Allocations
    7. 27. Setting Up Your Data with Structures
      1. Defining a Structure
      2. Putting Data in Structure Variables
  16. Part V: Files and Functions
    1. 28. Saving Sequential Files to Your Computer
      1. Disk Files
      2. Opening a File
      3. Using Sequential Files
    2. 29. Saving Random Files to Your Computer
      1. Opening Random Files
      2. Moving Around in a File
    3. 30. Organizing Your Programs with Functions
      1. Form Follows C Functions
      2. Local or Global?
    4. 31. Passing Variables to Your Functions
      1. Passing Arguments
      2. Methods of Passing Arguments
    5. 32. Returning Data from Your Functions
      1. Returning Values
      2. The return Data Type
      3. One Last Step: Prototype
      4. Wrapping Things Up
  17. Appendixes
    1. A. The ASCII Table
    2. B. The Draw Poker Program
  18. Index

Product information

  • Title: C Programming Absolute Beginner’s Guide, Third Edition
  • Author(s): Greg Perry, Dean Miller
  • Release date: August 2013
  • Publisher(s): Que
  • ISBN: 9780133149869