Beginning Programming with C For Dummies

Beginning Programming with C For Dummies




von: Dan Gookin

For Dummies, 2013

ISBN: 9781118737620

Sprache: Englisch

456 Seiten, Download: 2388 KB

Format:  EPUB, auch als Online-Lesen

geeignet für: geeignet für alle DRM-fähigen eReader geeignet für alle DRM-fähigen eReader Apple iPad, Android Tablet PC's Apple iPod touch, iPhone und Android Smartphones Online-Lesen


eBook anfordern

Mehr zum Inhalt

Beginning Programming with C For Dummies


Say “Hello, world” to Beginning Programming with C For Dummies, a book that transforms you from a well-meaning, caring human being into an admired element of the underground nerd subculture, the programmer.

Oh, yes, that’s a good thing.

When you learn to code in C, you become the ultimate master of a number of electronic gizmos. You can craft your own programs, dictating to computers, tablets, and cell phones your very whims and desires. And the electronics dutifully obey. Given the information offered in this book, you can pass that programming class, impress your friends, be admired by Hollywood, or even start your own software company. Yes, learning to program is a worthy investment of your time.

This book helps make learning how to program understandable and enjoyable. You don’t need any programming experience — you don’t even need to buy new software. You just need the desire to program in C and the ability to have fun while doing so.

Is the C Language Relevant?

An argument surfaces every few years that learning C is a road to nowhere. Newer, better programming languages exist, and it’s far better to learn them than to waste time learning C.


In a way, C is the Latin of computer languages. Just about every Johnny-come-lately programming language uses C syntax. C keywords and even certain functions find their way into other popular languages, from C++ to Java to Python to whatever the latest, trendy language could be.

My point is that once you learn C programming, all those other programming languages come easy. In fact, many of the books that teach those other languages often assume that you know a little C before you start out. That can be frustrating for any beginner — but not when you already know C.

Despite what the pundits and poobahs say, C is still relevant. Programming for microcontrollers, operating systems, and major software packages is still done using good ol’ C. You are not wasting your time.

The C Programming For Dummies Approach

As a programmer, I’ve toiled through many, many programming books. I know what I really don’t like to see, and, lamentably, I see it often — that is, where the author writes pages-long code or simply boasts about what he knows, impressing his fellow nerds and not really teaching anything. Too much of that type of training exists, which is probably why you’ve picked up this book.

My approach here is simple: Short programs. To-the-point demonstrations. Lots of examples. Plenty of exercises.

The best way to learn something is by doing it. Each concept presented in this book is coupled with sample code. The listings are short enough that you can quickly type them in — and I recommend that you do so. You can then build and run the code to see how things work. This immediate feedback is not only gratifying, it’s also a marvelous learning tool.

Sample programs are followed by exercises you can try on your own, testing your skills and expanding your knowledge. Suggested answers to the exercises can be found on this book’s companion website:

How This Book Works

This book teaches the C programming language. It starts out by assuming that you know little to nothing about programming, and it finishes by covering some of the more advanced C operations.

To program in C, you need a computer. This book makes no assumptions about the computer you select: It can be a Windows PC, a Macintosh, or a Linux system. Central to all systems, and to programming in this book, is to set up and use the Code::Blocks integrated development environment, or IDE. Steps to do so are offered in Chapter 1.

This book also wastes no time, getting you started immediately in Chapter 1. Nothing is introduced without a full explanation first, although due to the nature of programming, I’ve made a few exceptions; they’re carefully noted in the text. Otherwise, the book flows from front to back, which is how you can best read this book.

C language keywords and functions are shown in monofont text, as in printf() and break. Some keywords, such as for and If, may make the sentence read in a goofy way, which is why those words are shown in monofont.

Filenames are shown in monospace type, such as program.exe.

If you need to type something, that text is shown in bold. For example, "Type the blorfus command" means that you should type blorfus at the keyboard. You're directed when to press the Enter key, if at all.

When working numbered steps, text to type appears in regular (roman) type:

3. Type exit and press the Enter key.

You type the word exit and then press the Enter key.

Program samples are shown as snippets on the page, similar to this one:

if( i == 1)

    printf("eye won");

You don’t need to type an example unless you’re directed to do so.

Full program listings are shown and numbered in each chapter; for example:

Listing 1-1: The Code::Blocks Skeleton

#include <stdio.h>

#include <stdlib.h>


int main()


    printf("Hello world!\n");



Because of this book’s margins, text in a listing may occasionally wrap, extending from one line to the next. You do not need to split up your code in a similar manner, and I remind you whenever such a thing occurs.

The listings in this book don’t contain line numbers, but the editor in Code::Blocks does (as do many popular text editors). This book references the sample code listings by using line numbers. Use the line numbers in your editor to reference the code.

Exercises are numbered by chapter and then sequentially. So the third exercise in Chapter 13 is Exercise 13-3. You’re directed in the text to work an exercise. Here’s an example:

Exercise 1-1: Type the source code from Listing 1-1 into the Code::Blocks editor. Save it under the filename ex0101. Build and run.

Answers for all exercises can be found on the web:

Go to that page if you want to copy and paste the source code as well; I don’t offer source code archives because you learn best when you type in the exercises. Or I’ll grant you a copy-and-paste, but, seriously, the source code is so short that you can type it quickly.

Icons Used in This Book

This icon flags information worthy enough to remember. Though I recommend remembering as much as you can, these icons flag the stuff you just can’t forget.

A tip is a suggestion, a special trick, or something super fancy to help you out.

This icon marks something you need to avoid. It’s advice that could also be flagged with a Tip or Warning icon but has dire consequences if ignored.

Face it: All of programming is technical. I reserve the use of this icon for extratechnical tidbits, asides, and anecdotes. Call it “nerd stuff.”

Parting Thoughts

I enjoy programming. It’s a hobby, and I find it incredibly relaxing, frustrating, and rewarding. I assume that more than a few other people share these feelings, but you may also be a struggling student or someone who wants a career. Regardless, enjoy programming. If you can imagine the program you want to write on a screen, you can make it happen. It may not happen as fast as you like, but it can happen.

Please work the exercises in this book. Try some on your own, variations on a theme. Continue working at problems until you solve them. The amazing thing about programming is that no single, absolutely correct way to do something exists. Anytime you try, you’re learning.

If possible, find a programming friend who can help you. Don’t make them do the work for you or explain how things run, but rely on them as a resource. Programming can be a solo thing, but it’s good to occasionally commiserate with others who also program in C — or in any language.

This book has a few companion websites.

To review the answers to the exercises, find supplemental information, and see what’s new, visit the following site:

For bonus articles and the code files from the book, visit:

For some helpful tips on programming in C, check out the Cheat Sheet at:

You can also write me an e-mail at

I’m happy to hear from you, although I cannot write your code. I also cannot explain university assignments. (I don’t do B-trees. No one does.) And if...




Hier gelangen Sie wieder zum Online-Auftritt Ihrer Bibliothek