Will the following program compile? If so, what does it write to the monitor?
#include <stdio.h>
char a=8, b=9;
int g ( int x, int y);
int g( int a, int b )
{
printf("scope g: a=%d b=%d \n", a, b );
}
int main ( void )
{
g( 1, 2 ) ;
printf("scope m: a=%d b=%d\n", a, b );
return 0 ;
}
The third non-blank line of the program is a function prototype, a declaration (but not a definition) of a function. In this program it is not needed, since the function definition follows immediately.
It does not hurt to have an unneeded prototype. Sometimes programmers put a prototype for every function in a file at the beginning of that file.