Function prototypes

In the definitions of C libraries, the header of a function is specified in a form similar to that used in a function declaration. The names of parameters are not needed, however. Such definitions allow us to use functions without seeing their internal workings. The prototypes for the functions above are:
    void PrintTwo(int, int);
    int Larger(int, int);
If we want to use functions which already exist as linkable object files, we introduce them to our program as below. The compiler assumes that they exist in a library and will be linked in before execution. stdio.h, stdlib.h etc. contain prototypes of standard functions in this form. It is often convenient to build our own libraries of functions which we can re-use in future programs.
void PrintTwo(int, int);
int Larger(int, int);
These two declarations could be placed in a header file and introduced with a #include directive. Building and using libraries is described elsewhere in these notes.


Next - Recursion.

Back to Contents page.