Passing variable #of args

Dave Hammond daveh at marob.MASA.COM
Fri Jan 20 23:38:07 AEST 1989


Two [semi-related] questions, first:

Given B() which expects 3 arguments passed to it, it's reasonably
obvious what can occur when A() invokes B() and passes less than 3 args.

What potential problems exist if A() passes *more* than 3 args to B()?
It seems to me that this would harm nothing, since the extra stuff
ends up beyond the current stack position.

Second:

I was surprised to see the following in a "GNU-something" source file:

lprintf(fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,10)
char *fmt;
{
	char buf[BUFSIZ];
	sprintf(buf,fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,10)
	...
}

Given the availability of varargs, is this style still acceptable and,
more importantly, is it portable?

--
Dave Hammond
...!uunet!masa.com!{marob,dsix2}!daveh



More information about the Comp.lang.c mailing list