Functions

The rules governing C functions are explained in Chapter 2, “Functions.”

Every C program must have at least one function, named main, which marks the beginning and end of the program's execution. Every executable statement in a C program must occur within a function.

Variables can be declared inside or outside functions. Variables declared inside a function are “local” and can only be accessed in that function. Variables declared outside all functions are “global” and can be accessed from any function in your program.

You call a C function by stating its name. If the function requires “arguments” (data), you list the arguments in the parentheses that follow the function name. Arguments that you pass to a function become local variables in the function.

A function can return a value (using the return keyword) or return nothing. If the function contains no return statement, it ends automatically when execution reaches the closing brace of the function definition.

A function “prototype” (declaration) tells QuickC the function's name, the type of value it returns, and the number and type of arguments it requires. Function prototypes normally appear near the beginning of the program. They allow QuickC to check the accuracy of every reference to the function.