Appendix A. C 101
This appendix covers the basics of the language. It’s not for everyone.
-
If you already have experience writing code in a common scripting language, like Python, Ruby, or Visual Basic, this appendix will be at your level. I don’t have to explain to you what variables, functions, loops, or other basic building blocks are, so the main headings of this appendix are about the big differences between C and typical scripting languages.
-
If you learned C a long time ago and are feeling rusty, skimming this tutorial should remind you of the quirks that make C different and unique.
-
If you already work with C on a regular basis, don’t bother reading this appendix. You may also want to skip or skim the early parts of Part II as well, which are aimed at common errors and misunderstandings about the core of the language.
Don’t expect to be an expert in C by the end of this tutorial—there’s no substitute for real experience with the language. But you will be in a position to get started with Part II of this book and find out about the nuances and useful customs of the language.
The Structure
I’ll kick off the tutorial the way Kernighan & Ritchie did in their 1978 blockbuster book: with a program to say hello.
//tutorial/hello.c
#include <stdio.h>
int
main
(){
printf
(
"Hello, world.
\n
"
);
}
The double slashes on the first line indicate a comment that the compiler will ignore. All of the code samples in this appendix marked with a file name like this are available online ...
Get 21st Century C, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.