Each program must have a starting point. When you run a program, the operating 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 program. 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 parentheses, 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() function is the first function in a C program. It’s required.
See also:
No comments:
Post a Comment