Node:A word about style, Next:, Previous:The form of a C program, Up:The form of a C program



A word about style

The code examples above are simple, but they illustrate the control flow of a C program, or the order in which its statements are executed. You should note that these programs are written in "old-fashioned" C, as the language existed before ANSI Standard C -- the version in which most C programs are now written. The above programs are also missing several key elements that most C programs have, such as header files and function prototypes. Finally, they do not show good style; if you wish to submit programs you write to the Free Software Foundation, you should consult its advice on how best to use the C language.

You may wonder why we chose old-style C for these first few examples, even though people proverbially learn best what they learn first. We did so because pre-ANSI C is considerably simpler than the present form, and also because as you develop as a C programmer, you will probably run across some old C code that you will want to read.

You may also wonder why a savvy programmer would want to follow the ANSI Standard, which was drafted by committee, or even the GNU guidelines. Isn't programming free software all about freedom? Yes, but following the ANSI Standard ensures that your code can be easily compiled on many other computer platforms, and the GNU guidelines ensure that your code can be read by other programmers. (We will introduce good C style in our examples soon. Meanwhile, you can examine the GNU guidelines later in the book. See Style.)