number of arguments function for 4.1bsd VAX cc(1) -- TYPO FIX

Gordon V. Cormack gvcormack at watdaisy.UUCP
Mon Feb 25 02:57:59 AEST 1985


This sample program illlustrates a much simpler way to find the
number of arguments to a function on the VAX, and to access an
indeterminate number of arguments.  

    #include <stdio.h>

    main()
    {
	pr_args(1);
	pr_args(1, 2, 3);
	pr_args(1, 2, 3, 4);
    }
    pr_args(args)
	int args;
    {
	int nargs, *argp, i;
	argp = &args;
	nargs = argp[-1];
	printf("Called with %d args: ", nargs);
	for(i=0; i<nargs; i++) printf( "%d ", argp[i] );
	putchar('\n');
    }
-- 
Gordon V. Cormack      CS Department, University of Waterloo
   gvcormack at watdaisy.uucp     gvcormack%watdaisy at waterloo.csnet



More information about the Comp.lang.c mailing list