Wednesday, Oct 17th

Last update12:59:40 PM GMT

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

Write e-mail

Without a prototype, there would be 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 <stdio.h>

/*
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);
}
argaiv1608

Share this post



Web Hosting