From: "A. Jans-Beken" Newsgroups: comp.os.msdos.djgpp,rec.games.programmer,alt.games.programming Subject: Help with variable argument-list (va_list) Date: Thu, 28 Sep 2000 21:00:03 +0200 Organization: World Access Lines: 44 Message-ID: <39D39533.33F46DA4@wxs.nl> NNTP-Posting-Host: ipc3797b69.dial.wxs.nl Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reader3.wxs.nl 970167011 13271882 195.121.123.105 (28 Sep 2000 18:50:11 GMT) X-Complaints-To: abuse AT wxs DOT nl NNTP-Posting-Date: 28 Sep 2000 18:50:11 GMT X-Mailer: Mozilla 4.7 [en-gb] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I am trying to create a wrapper for a function that uses a variable argument list (like printf). I have tried the code below, and the first argument works, but not the second. What is wrong in this example? (the program compiles with DJGPP 2.95) // ---- 8< ---- 8< ---- // file: test.cpp #include #include #include void test_me(char *fmt, ... ) { va_list ap; va_start(ap,fmt); printf(fmt,va_arg(ap,va_list)); va_end(ap); } int main() { cout << "Test of va_list and co...\n"; cout << "=========================\n\n"; printf("The printf() function is working fine.\n"); int i = 3; char *s = "Hello dear people"; // The function test_me is a wrapper for printf. // How can I wrap a function with a variable number // of parameters? test_me("My arguments are %d and %s\n",i,s); return 0; } // ---- 8< ---- 8< ---- Please send answers to "jansb000 AT wxs DOT nl"