1) Define or prototype the function.
2) Use it in a function elsewhere.
Examples:
Code:
int function( void ); /* A function prototype. */
int main( void )
{
function( ); /* Call the function. */
}
int function( void ) /* Define the function. */
{
printf("Function called.\n");
return 0;
}
Or, without a prototype:
Code:
int function( void ) /* Define the function. */
{
printf("Function called.\n");
return 0;
}
int main( void )
{
function( ); /* Call the function. */
}
In the second example, I don't need a prototype because I have defined the entire function before I ever call it. In the first example, 'main' wouldn't have been aware of the function if I didn't prototype it first, because it was declared after main tried to use it.
Quzah.