Variable number of arguments

This is a discussion on Variable number of arguments within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to use #include <stdarg.h> in order to design a function that can be called with either a different ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    35

    Variable number of arguments

    I'm trying to use #include <stdarg.h> in order to design a function that can be called with either a different number or type of arguments.

    wutil.h:
    Code:
    #ifndef _WUTIL_H
    #define _WUTIL_H
    
    #include <windows.h>
    #include <stdarg.h>
    
    void alert(String s, ... );
    
    #endif
    wutil.c:
    Code:
    #include "wutil.h"
    
    void alert(String s, ... )
    {
        
    }
    When I try to compile it I get the following error:
    Code:
    D:\C\setup01\wutil.c In file included from wutil.c
    D:\C\setup01\wutil.h parse error before "s"
    What am I doing wrong?

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Where is String defined

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    35
    Ooops. I wrote it wrong :-)

    I'm jumping between Java and C, C++ and VBScript, etc., and sometimes I just go crazy.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote Originally Posted by dit6a9
    Ooops. I wrote it wrong :-)

    I'm jumping between Java and C, C++ and VBScript, etc., and sometimes I just go crazy.

    Hehe...it happens!


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Number Guessing
    By blacknapalm in forum C Programming
    Replies: 2
    Last Post: 10-01-2008, 02:48 AM
  2. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 01:42 PM
  3. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM
  4. Variable Arguments Question
    By moonwalker in forum C Programming
    Replies: 8
    Last Post: 08-04-2002, 10:08 AM
  5. Functions with a variable number of arguments
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2002, 02:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21