1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.

Monday, April 6, 2009

Will C allow passing more or less arguments than required to a function.

It wont if the prototpe is around. It will ideally scream out with an error like


Too many arguments


or


Too few arguments



But if the prototype is not around, the behavior is undefined.

Try this out


#include

/*
int foo(int a);
int foo2(int a, int b);
*/

int main(int a)
{
int (*fp)(int a);

a = foo();
a = foo2(1);

exit(0);
}

int foo(int a)
{
return(a);
}

int foo2(int a, int b)
{
return(a+b);
}

 
# #