On 9/9/05, _z33 <[EMAIL PROTECTED]> wrote:
> Steve Graegert wrote:
> > I have modified the code to clarify my thoughts:
> >
> > #include <stdio.h>
> >
> > /* prototype */
> > void add(); /* call with arbitrary number of arguments */
> >
> > void add (int a, int b, int c) {
> > printf ("inside function: add(%d, %d)\n", a, b);
> > return;
> > }
> >
> > int main (void) {
> > /* call function add with some parameters */
> > add(5, 1);
> > getc(stdin);
> >
> > return (0);
> > }
> >
> > Do you see the difference? No warning is issued, because there is
> > nothing wrong with it (it is not recommended by ANSI C99 but still
> > valid).
> >
>
> Inside "main", did you mean to write the function call as " add (5,
> 1, <some number>); ". Cos' when I copy the code, and try to run it, it
> throws me this error message during compilation.
> - too few arguments to function `add'-
No, the code given is exactly what I wanted to show. (The code you
provided was Windows code and I tested it under Windows without
complaints.)
Unfortunately, under Linux you cannot switch to "traditional" since it
would clash with libc which is an ISO C library. Under Solaris
(SPARCWorx) you may want to try -traditional and -fd. As far as I
know only SunOS and HP-UX (besides Windows) come with a native K&R C
compiler. All others do prototype checking.
> >> Am I fundamentally going wrong in my understanding of functions?
> >
> >
> > No you're not. You're just curious :-)
>
> Thanks!
>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming"
in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html