Make your own free website on
'; zhtm += ''; zhtm += '

' + pPage + ''; zhtm += ''; figDoc.write(zhtm); figDoc.close(); popUpWin.focus(); } //--> Teach Yourself C in 21 Days -- Introduction


Next chapterContents


As you can guess from the title, this book is set up so that you can teach yourself the C programming language in 21 days. Despite stiff competition from newer languages such as C++ and Java, C remains the language of choice for people who are just learning programming. For reasons we detail on Day 1, you can't go wrong in selecting C as your pro-gramming language.

We think you've made a wise decision selecting this book as your means of learning C. Although there are many books on C, we believe this book presents C in the most logical and easy-to-learn sequence. The fact that previous editions have constantly been on the best-seller lists indicates that readers agree with us! We designed this book for you to work through the chapters in order on a daily basis. We don't assume any previous programming experience on your part, although experience with another language, such as BASIC, might help you learn faster. We also make no assumptions about your computer or compiler; this book concentrates on teaching the C language, regardless of whether you're using a PC, a Mac, or a UNIX system.

This Book's Special Features

This book contains some special features to aid you on your path to C enlightenment. Syntax boxes show you how to use specific C concepts. Each box provides concrete examples and a full explanation of the C command or concept. To get a feel for the style of the syntax boxes, look at the following example. (Don't try to understand the material; you haven't even reached Day 1!)

#include <stdio.h>
printf( format-string[,arguments,...]);

printf() is a function that accepts a series of arguments, each applying to a conversion specifier in the given format string. It prints the formatted information to the standard output device, usually the display screen. When using printf(), you need to include the standard input/output header file, STDIO.H.

The format-string is required; however, arguments are optional. For each argument, there must be a conversion specifier. The format string can also contain escape sequences. The following are examples of calls to printf() and their output:

Example 1

#include <stdio.h>
    printf( "This is an example of something printed!");

Example 1 Output

This is an example of something printed!

Example 2

printf( "This prints a character, %c\na number, %d\na floating point,
%f", `z', 123, 456.789 );

Example 2 Output

This prints a character, z
a number, 123
a floating point, 456.789

Another feature of this book is Do/Don't boxes, which give you pointers on what to do and what not to do.

DO read the rest of this section. It explains the Workshop sections that appear at the end of each day.

DON'T skip any of the quiz questions or exercises. If you can finish the day's workshop, you're ready to move on to new material.

You'll encounter Tip, Note, and Warning boxes as well. Tips provide useful shortcuts and techniques for working with C. Notes provide special details that enhance the explanations of C concepts. Warnings help you avoid potential problems.

Numerous sample programs illustrate C's features and concepts so that you can apply them in your own programs. Each program's discussion is divided into three components: the program itself, the input required and the output generated by it, and a line-by-line analysis of how the program works. These components are indicated by special icons.

Each day ends with a Q&A section containing answers to common questions relating to that day's material. There is also a Workshop at the end of each day. It contains quiz questions and exercises. The quiz tests your knowledge of the concepts presented on that day. If you want to check your answers, or if you're stumped, the answers are provided in Appendix G.

You won't learn C just by reading this book, however. If you want to be a programmer, you've got to write programs. Following each set of quiz questions is a set of exercises. We recommend that you attempt each exercise. Writing C code is the best way to learn C.

We consider the BUG BUSTER exercises most beneficial. A bug is a program error in C. BUG BUSTER exercises are code listings that contain common problems (bugs). It's your job to locate and fix these errors. If you have trouble busting the bugs, these answers also are given in Appendix G.

As you progress through this book, some of the exercise answers tend to get long. Other exercises have a multitude of answers. As a result, later chapters don't always provide answers for all the exercises.

NOTE: The source code in this book was compiled and tested on the following platforms: DOS, Windows, System 7.x (Macintosh), UNIX, and OS/2. In addition, readers of previous editions of this book have used the code on virtually every platform that supports C!

A new feature of this edition is the Type & Run sections. You'll find six of these throughout the book. Each Type & Run contains a short C program that does something fun or useful while it illustrates C programming techniques. You can type these listings in and run them. After you've entered them, you can also play with the code to see what else you can make it do. The Type & Runs are for you to experiment with. We hope you have fun playing with these additional code listings!

Where You Can Obtain This Book's Code

For your convenience, the code listings in this book are available on the Internet and CompuServe. Alternatively, you can purchase a CD-ROM that contains all the source code. As a bonus, the CD-ROM includes the GNU C compiler and other useful utilities. The order form for the CD-ROM is at the back of this book.

Here's how you access the source code from the Internet:

Internet: World Wide Web

Remember that directory and filenames on the Internet are case-sensitive on some servers.

Conventions Used in This Book

This book uses different typefaces to help you differentiate between C code and regular English, and also to help you identify important concepts. Actual C code appears in a special monospace font. In the examples of a program's input and output, what the user types appears in bold monospace. Placeholders--terms that represent what you actually type within the code--appear in italic monospace. New or important terms appear in italic.

Next chapterContents