Variable number of arguments to a function

Larry Jones scjones at sdrc.UUCP
Mon May 7 05:00:03 AEST 1990


In article <3697 at iitmax.IIT.EDU>, thssvhj at iitmax.IIT.EDU (vijay hemraj jadhwani) writes:
> Below are the three different cases of function references (or usage).
> Case 1. ACTUAL NO. OF ARGUMENTS < NO. OF ARGUMENTS IN THE FUNC. DEFINITION
> 
> Case 2.  ACTUAL NO. OF ARGUMENTS > NO. OF ARGUMENTS IN THE FUNC. DEFINITION
> 
> Case 3: ARGUMENT TYPE IS DIFFERENT THAN THE EXPECTED ARGUMENT TYPE
> 
> Questions -
> 1. Which of the above 3 cases are correct and which are not? Why ?

None of them is correct.  The number and type of arguments in a
call MUST match the number and type in the definition.  See the
ANSI C standard.

> 2. If I want to remove any "lint" warnings, for argument number mismatch,
>    what should I do ? i.e. I need a scheme to be able to pass variable
>   number of arguments to myprint(). Also it would be nice , if I could 
>   also have an ability to  pass any "type" of arguments to myprint().

Look up <stdargs.h> or <varargs.h> and vprintf().
----
Larry Jones                         UUCP: uunet!sdrc!scjones
SDRC                                      scjones at SDRC.UU.NET
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
"You know how Einstein got bad grades as a kid?  Well MINE are even WORSE!"
-Calvin



More information about the Comp.lang.c mailing list