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

C All-in-One Desk Reference For Dummies

Dan Gookin

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

C All-in-One Desk Reference For Dummies

Dan Gookin

Book details
Book preview
Table of contents
Citations

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

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
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.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
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.
Do you support text-to-speech?
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.
Is C All-in-One Desk Reference For Dummies an online PDF/ePUB?
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 Informatik & Programmierung in C. We have over one million books available in our catalogue for you to explore.

Information

Publisher
For Dummies
Year
2011
ISBN
9781118054246
Edition
1

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