....
funcDef1(....)
{
...
}
....
funcDef2(....)
{
...
}
....
|
....
<---- Here
funcDef1(....)
{
<---- Here
...
}
....
<---- Here
funcDef2(....)
{
<---- Here
...
}
....
<---- Here
|
The scope (= validity) of the function declaration depends on where you place the function declaration
|
Example:
....
funcDef1(....)
{
... square() is NOT declared here
}
....
double square( double x ) ; // Declare "square()"
funcDef2(....)
{
... square() is declared here
}
....
|
|
Example:
int f( ... )
{
double square( double x); // declare square() function
... // square() is declared here
}
int g( ... )
{
// square() is not declared here !!!
}
|
|
Example:
extern double square ( double );
extern double square ( double ); // Repeat is OK...
int main( int argc, char *argv[] )
{
double a, b;
a = 4.0;
b = square( a ); // Call square
printf("Square of %lf = %lf\n", a, b);
}
|