就是比如可以带2个或者3个参数之类的,记得是用...来实现的,但查不到啦。
谢谢

解决方案 »

  1.   

    void YourFunc(...)
    {
    }参数用 va_list 分析和取出。
      

  2.   

    #include <stdio.h>
    #include <stdarg.h>//  Declaration, but not definition, of ShowVar.
    int ShowVar( char *szTypes, ... );void main()
    {
        ShowVar( "fcsi", 32.4f, 'a', "Test string", 4 );
    }
    //  ShowVar takes a format string of the form
    //   "ifcs", where each character specifies the
    //   type of the argument in that position.
    //
    //  i = int
    //  f = float
    //  c = char
    //  s = string (char *)
    //
    //  Following the format specification is a list
    //   of n arguments, where n == strlen( szTypes ).
    void ShowVar( char *szTypes, ... )
    {
        va_list vl;
        int i;    //  szTypes is the last argument specified; all
        //   others must be accessed using the variable-
        //   argument macros.
        va_start( vl, szTypes );    // Step through the list.
        for( i = 0; szTypes[i] != '\0'; ++i )
        {
            union Printable_t
            {
                int     i;
                float   f;
                char    c;
                char   *s;
            } Printable;        switch( szTypes[i] )    // Type to expect.
            {
            case 'i':
                Printable.i = va_arg( vl, int );
                printf( "%i\n", Printable.i );
                break;        case 'f':
                Printable.f = va_arg( vl, float );
                printf( "%f\n", Printable.f );
                break;        case 'c':
                Printable.c = va_arg( vl, char );
                printf( "%c\n", Printable.c );
                break;        case 's':
                Printable.s = va_arg( vl, char * );
                printf( "%s\n", Printable.s );
                break;        default:
                break;
            }
        }
        va_end( vl );
    }
      

  3.   

    for example:
    void SaveMsg(TCHAR* szFormat,...)  throw()
    {
    TCHAR szBuffer[65536];
    ZeroMemory(szBuffer,65536);
    va_list pArgs;
    SYSTEMTIME st;
    GetLocalTime(&st);
    va_start(pArgs, szFormat);
    vsprintf(szBuffer, szFormat, pArgs);
    va_end(pArgs);
    ...
    }
      

  4.   

    比如这个:
    int sprintf (char * szBuffer, const char * szFormat, ...)
    {
      int     iReturn ;
      va_list pArgs ;
      va_start (pArgs, szFormat) ;
      iReturn = vsprintf (szBuffer, szFormat, pArgs) ;
      va_end (pArgs) ;
      return iReturn ;
    }