Possible Duplicates:
C++ preprocessor __VA_ARGS__ number of arguments
How to count the number of arguments passed to a function that accepts a variable number of arguments?
To learn variable parameter function, I write a demo:
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
int foo(int n, int m, ...);
int
main (int argc, char *argv[])
{
    int n = 10;
    int m = 15;
    int p = 20;
    //foo (n, m);
    foo(n, m, 20);
    return EXIT_SUCCESS;
}
int foo (int n, int m, ...)
{
    va_list ap;
    int p;
    char *str;
    va_start (ap, m);
    p = va_arg (ap, int);
    n = m + p;
    printf ("%d.\n", n);
    va_end (ap);
    return 0;
}
I want to know how to deal with the function if it has only two parameters. (For this demo, if only n and m, after running foo, I want to get result: n = n+m.)
 
     
     
     
     
     
    