O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Structure of a Simple Program

Now that you've seen a specific example, you are ready for a few general rules about C programs. A program consists of a collection of one or more functions, one of which must be called main(). The description of a function consists of a header and a body. The header contains preprocessor statements, such as #include, and the function name. You can recognize a function name by the parentheses, which may be empty. The body is enclosed by braces ({}) and consists of a series of statements, each terminated by a semicolon (see Figure 2.4). The example in this chapter had a declaration statement, announcing the name and type of variable being used. Then it had an assignment statement giving the variable a value. Next, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required