Function Prototypes

Summary: Function prototypes allow QuickC to check every function reference for accuracy.

A function can be declared in much the same way as a variable. Function declarations, often called “prototypes,” allow QuickC to do “type checking.” Given the information in the prototype, QuickC can check every subsequent use of the function to make sure you pass the right number and type of arguments and use the correct return type.

A function prototype gives the following information:

The function's name

The type of value the function returns

A list of arguments the function requires

The VOLUME.C program contains one function prototype, for the sphere function:

float sphere( int rad );

The prototype states that the sphere function returns a float (floating-point) value and requires one int (integer) argument.