To get the most out of this book
To use this book, you will need a basic text editor, a terminal or console application, and a compiler. Descriptions of each of these and how to download and use them are provided in Chapter 1, Running Hello, World!. Here are the technical requirements for this book:
All of the software given in the table are either built into the operating system or are free to download.
To install GCC on certain Linux OSs, follow these steps:
- If you are running an RPM-based Linux, such as Red Hat, Fedora, or CentOS, on the command line in Terminal, enter the following:
$ sudo yum group install development-tools
If you are running Debian Linux, on the command line in Terminal, enter the following:
$ sudo apt-get install build-essential
- To verify your installation of GCC or Clang for any platform, on the command line in Terminal, enter the following:
$ cc --version
Whichever version of this book you are using, digital or hard copy, we advise you to type the code yourself. After you do that, you can access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
If you are an absolute beginner, once you have the necessary development tools, you will need to learn how to read a programming book. If you have taken an algebra course or a calculus course in school, then you will need to approach learning from a programming book in a similar fashion:
- Read through the chapter to get an overview of the concepts being presented.
- Begin the chapter again, this time typing in each program as you encounter it. Make sure you get the expected output before moving on. If you don't get the expected output, try to figure out what is different in your program from the one given. Learning to program is a lot like learning math – you must do the exercises and get the programs to work. You cannot learn to program just by looking at programs; to learn to program, you must program. There is no way around that.
- Focus on memorizing keywords and syntax. This will greatly speed up your learning time.
- Be aware that you will need to sharpen the precision of your thinking. The syntax of computer language is extremely precise, and you will need to pay extra attention to it. You will also have to think much more precisely and in sometimes excruciating detail about the steps needed to solve a particular problem.
- Review both the concepts and example programs. Make a note of anything you don't understand.
If you are an experienced programmer who is new to C, I still strongly advise you to first skim the text and examples. Then, enter the programs and get them to work on your system. This will help you to learn C syntax and its idioms more quickly.
I have found that it is important to understand what kind of book you are reading so that you can use it most appropriately. There are several kinds of computer programming books:
- Conceptual books, which deal with the underlying ideas and motivation for the topics they present. Kernighan and Ritchie's The C Programming Language and Effective C: An Introduction to Professional C Programming, by Seacord, are two such books.
- Textbooks, which go through every major area of the language, sometimes in gory detail and usually with a lot of code snippets. Deitel and Deitel's books, as well as C Programming: A Modern Approach, by K. N. King, are examples of these. They are often best used in a formal programming course.
- Reference books, which describe the specifics of each syntax element. C: A Reference Manual, by Harbison and Steele, is one such book.
- Cookbooks, which present specific solutions to specific problems in a given language. Advanced C Programming by Example, by Perry, Expert C Programming: Deep Secrets, by Van Der Linden, and Algorithms in C, by Sedgewick, are examples of these.
- Topical books, which delve deeply into one or more aspects of a programing language. Pointers in C, by Reek, is one example.
- Practice books, which deal with how to address programming with C generally. C Interfaces and Implementations, by Hanson, and 21st Century C: C Tips from the New School, by Klemens, are two examples of these.
There are different ways to use these books. For instance, read a conceptual book once, but keep a reference book around and use it often. Try to find cookbooks that offer the kinds of programs you are likely to need and use them as needed.
I think of this book as a combination of a C cookbook, a C reference book, and a C practice book. This is not intended to be a textbook. All of the programs are working examples that can be used to verify how your compiler behaves on your system. Enough of the C language has been included that it may also be used as a first-approximation reference. Throughout, my intent has been to show good programming practice with C.
I expect that Learn C Programming will not be your last book on C. When you consider other C books, be sure that they pertain to C99 at a minimum; ideally, they should include C11, C17, or C23. Most C code before C99 is definitely old-school; more effective programming practices and methods have been developed since C99 and before.