A C program consists of individual building blocks called functions , which can invoke one another. Each function performs a certain task. Ready-made functions are available in the standard library; other functions are written by the programmer as necessary. A special function name is main( ): this designates the first function invoked when a program starts. All other functions are subroutines.
illustrates the structure of a C
program. The program shown consists of the functions
, and prints the beginning of a text
file to be specified on the command line when the program is started.
Figure 1-1. A C program
that make up the functions, together with the necessary declarations
and preprocessing directives, form the source
code of a C program. For small programs, the source code
is written in a single source
. Larger C programs consist of several
source files, which can be edited and compiled separately. Each such
source file contains functions that belong to a logical unit, such as
functions for output to a terminal, for example. Information that is
needed in several source files, such as declarations, is placed in
These can then be included in each source file via the
Source files have names ending in .c; header files have names ending in .h. A source file together ...