Thread: Variable number of arguments

  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,793
    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,793
    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, 01:48 AM
  2. help with a source code..
    By venom424 in forum C++ Programming
    Replies: 8
    Last Post: 05-21-2004, 12: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, 09:08 AM
  5. Functions with a variable number of arguments
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2002, 01:12 AM