The first program compiled properly.second gave error saying too few argument for foo…
is global declaration ignored by the compiler in both programs?
first program:
#include<stdio.h>
void foo();
int main()
{
void foo(int);
foo(1);
return 0;
}
void foo(int i)
{
printf("2 ");
}
void f()
{
foo(1);
}
second program:
void foo();
int main()
{
void foo(int);
foo();
return 0;
}
void foo()
{
printf("2 ");
}
void f()
{
foo();
}
The inner declaration hides declarations at the global scope. The second program fails because the declaration
void foo(int);hides the global declarationvoid foo();; so when you sayfoowithinmainyou are referring to the one taking anintas argument.