C All-in-One Desk Reference For Dummies
eBook - ePub

C All-in-One Desk Reference For Dummies

  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

C All-in-One Desk Reference For Dummies

About this book

Ready, set, code! A user-friendly guide introducing the C programming language to new and intermediate coders

The C programming language and its direct descendants are widespread and among the most popular programming languages used in the world today. The enduring popularity of C continues because C programs are fast, concise, and run on many different systems. Flexible and efficient, C is designed for a wide variety of programming tasks: system-level code, text processing, graphics, telecommunications, and many other application areas. C All-in-One Desk Reference For Dummies is for beginning and intermediate C programmers and provides a solid overview of the C programming language, from the basics to advanced concepts, with several exercises that give you real-world practice.

C All-in-One Desk Reference For Dummies covers everything users need to get up to speed on C programming, including advanced topics to take their programming skill to the next level. Inside you'll learn

  • The entire development cycle of a C program: designing and developing the program, writing source code, compiling the code, linking the code to create the executable programs, debugging, and deployment
  • The intricacies of writing the code -- the basic and not-so-basic building blocks that make up the source code
  • Thorough coverage of keywords, program flow, conditional statements, constants and variables, numeric values, arrays, strings, functions, pointers, debugging, prototyping, and more
  • Dozens of sample programs you can adapt and modify for your own use

Written in plain English, this friendly guide also addresses some advanced programming topics, such as

  • Programming for the Linux/Unix console
  • Windows and Linux programming
  • Graphics programming
  • Games programming
  • Internet and network programming
  • Hardware programming projects

The book includes a handy appendix that shows you how to set up your computer for programming, how to select and use a text editor, and fix up the compiler, to ensure you're ready to work the author's examples. Written by Dan Gookin, the author of the first-ever For Dummies book (and several others) who's known for presenting complex material in an easy-to-understand way, this comprehensive guide makes learning the C programming language simple and fun. Grab your copy of C All-in-One Desk Reference For Dummies, so you can start coding your own programs.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access C All-in-One Desk Reference For Dummies by Dan Gookin in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in C. We have over one million books available in our catalogue for you to explore.

Information

Chapter 1: Your Basic C Program

In This Chapter

bullet
Finding out some C language history
bullet
Building a C program one piece at a time
bullet
Understanding the C program skeleton
L earning a programming language is like trying to eat an entire banquet in one bite: You have so much to swallow at once, even to understand the most basic stuff, that it isn’t a question of where to start, but rather what not to eat so that you don’t get too sick too quickly.
This chapter provides a quick and dirty introduction to a single C language program. The chapter doesn’t even explain why things are necessary because, honestly, at this point in the game you’re probably more interested in accomplishing something than truly figuring out why something works. Don’t worry: That comes later. For now, this chapter offers a small taste of the feast to come.
Remember
Remember to use the basic folder or directory for the source code and program files in this book.

The Section Where the Author Cannot Resist Describing the History of C

In the beginning was Charles Babbage and his Analytical Engine, a machine he built in 1822 that could be programmed to carry out different computations. Move forward more than 100 years, where the U.S. government in 1942 used concepts from Babbage’s engine to create the ENIAC, the first modern computer.
To program Babbage’s computer, you had to literally replace stacks of gears. To make the ENIAC carry out different tasks, it had to be rewired by hand.
By the early 1950s, computer programming had evolved from rewiring to entering instructions using rows of switches. The process began with Professor John von Neumann, who in 1945 developed the concept of the function (or subroutine), the IF-THEN choice statement, and the repeating FOR loop. By 1949, Von Neumann had come up with a binary programming language he called Short Code. Then, in 1951, Grace Hopper developed the first compiler, which allowed the computer to be programmed using words and symbols rather than binary ones and zeroes. Computers could then be programmed with written instructions rather than by rewiring or throwing switches.
In the mid-1950s, the first major programming language appeared. Named FORTRAN, for formula translating system, it incorporated variables and introduced logical conditions to the art of programming. Then, in 1959, the COBOL programming language was developed as businesses began to adopt computers. COBOL was the first programming language with a truly English-like grammar.
The Algol language was developed at about the same time as COBOL. From Algol, many programming techniques were introduced that are still used today.
In 1968, Zurich professor Niklaus Wirth used Algol as a basis for the Pascal programming language. Pascal was designed as a teaching tool because it didn’t allow for sloppy programming and forced users to follow the rules of structured programming.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working with two languages: B (for Bell) and BCPL (Basic Combined Programming Language). Inspired by Pascal, Mr. Ritchie developed the C programming language.
The C language was used to write the Unix operating system. Ever since that first version of Unix in the early 1970s, a C compiler has always been a part of the operating system — even with Unix variations like Linux and Mac OS. It also explains why Unix comes with so many programming utilities. (Indeed, Unix is often called the “programmer’s operating system.”)
In 1983, C programmer Bjarne Stoustroup developed object oriented programming (OOP) extensions to the C language and created the C++ programming language. Even though it’s often taught as a separate subject, C++ is really about 95 percent original C. Even so, some purists stick with the original C language and don’t bother to discover that extra 5 percent of C++ — despite the power and flexibility it offers.
Branching off from C in the 1990s was another programming language: Java, from Sun Microsystems. Originally developed for interactive TV, the Java language truly found a home on the Web in 1994 and has been a popular Web programming language ever since.

Time to Program!

The C language has a certain structure to it — a form, a visual look, a feeling. Unlike in more freeform languages, you must obey traditions and rules to put together the most basic of C programs. That’s what gives the C language its look and feel.
The following sections introduce you to the basic structure of a simple C program — the skeleton. Each section builds on the next, so read them in order.
Ensure that you have read through Appendix A, which discusses how to set up the C language compiler on your computer and the basic steps for editing, compiling, and running a program.
One suggestion: Please save all the source code files for this book in the basic folder on your hard drive (prog/c/basic).

The basic, simplest C program

When you program a computer, you tell it exactly what to do. The instructions are given in a particular language — in this case, the C language. Those instructions are then compiled into object code. The object code is then linked with a C language library, and the result is an executable file or a program you can run on your computer. It’s just like magic!
I save the boring specifics for the next chapter. For now, consider the most basic of all programs:
Yes, that’s a blan...

Table of contents

  1. Title
  2. Contents
  3. Introduction
  4. Book I : Hello, C
  5. Chapter 1: Your Basic C Program
  6. Chapter 2: How It All Works
  7. Chapter 3: More Basics, Comments, and Errors
  8. Chapter 4: Introducing Numbers and Variables
  9. Chapter 5: More Variables and Basic I/O
  10. Chapter 6: Decision Time
  11. Chapter 7: Looping
  12. Chapter 8: Using Constants
  13. Chapter 9: Mysterious Math
  14. Chapter 10: It’s Only Logical
  15. Book II : Middle C
  16. Chapter 1: Variables from Beyond Infinity
  17. Chapter 2: The Madness of Printf()
  18. Chapter 3: Maniacal Math Functions
  19. Chapter 4: Not Truly Random
  20. Chapter 5: While Going Loopy
  21. Chapter 6: More Decision Making
  22. Chapter 7: The Goto Chapter
  23. Book III : Above C Level
  24. Chapter 1: Asking for Arrays
  25. Chapter 2: I Sing of Strings
  26. Chapter 3: Messing with Characters
  27. Chapter 4: Stinkin’ Structures
  28. Chapter 5: Creating Your Own Functions
  29. Chapter 6: Quitting Before You’re Done
  30. Chapter 7: More Variable Nonsense
  31. Book IV : Advanced C
  32. Chapter 1: Introduction to Evil Pointers
  33. Chapter 2: Getting to the *Point
  34. Chapter 3: Binary Bits
  35. Chapter 4: The Myth of the Array
  36. Chapter 5: Pointers and Strings
  37. Chapter 6: Crazy Arrays of Pointers
  38. Chapter 7: Functions and Pointers
  39. Chapter 8: Structures, Pointers, and the Malloc Deity
  40. Chapter 9: Does Anyone Have the Time?
  41. Chapter 10: Building Big Programs
  42. Chapter 11: Help!
  43. Book V : Disk Drive C
  44. Chapter 1: Just Your Standard I/O
  45. Chapter 2: Interacting with the Command Line
  46. Chapter 3: Hello, Disk!
  47. Chapter 4: More Formal File Writing and Reading
  48. Chapter 5: Random Access Files
  49. Chapter 6: Folder Folderol
  50. Chapter 7: Under New File Management
  51. Book VI : The Joy of Linked Lists
  52. Chapter 1: Why Linked Lists?
  53. Chapter 2: Dawn of the Database
  54. Chapter 3: Storing a Linked List on Disk
  55. Chapter 4: The Nightmare of the Double-Linked List
  56. Book VII : Appendixes
  57. Appendix A: The Stuff You Need to Know before Reading Everything Else in This Book
  58. Appendix B: ASCII Table
  59. Appendix C: Answers to Exercises
  60. Appendix D: C Language Keywords and Operators
  61. Appendix E: C Language Variable Types
  62. Appendix F: Escape Sequences
  63. Appendix G: Conversion Characters