Saturday, January 29, 2011

The big picture of a c program

Each program must have a starting point. When you run a program, the operat­ing system (OS) sends it off on its way — like launching a ship. As its last dockmaster duty, the OS hurls the microprocessor headlong into the program. The microprocessor then takes the program’s helm at a specific starting point.

In all C programs, the starting point is the main() function. Every C program has one; GOODBYE.C, ERROR.C, and all the other C programs you ever create. The main() function is the engine that makes the program work. The main() function is also the skeleton upon which the rest of the program is built.


main() is the name given to the first (or primary) function in every C pro­gram. C programs can have other functions, but main() is the first one.


In C, functions are followed by parentheses. The parentheses can be empty, or they can contain information — it all depends on the individ­
ual function.


When I write about C language functions in this book, I include the paren­theses, as in main().


A function is a machine — it’s a set of instructions that does something. C programs can have many functions in them, though the main() func­tion is the first function in a C program. It’s required.

 

See also:

Extra help in typing the GOODBYE.C source code

The compiler and the linker

How to compile goodbye.c?

No comments:

Post a Comment