Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Calls with a Variable Number of Arguments

Reply
Thread Tools

Re: Calls with a Variable Number of Arguments

 
 
markus_e
Guest
Posts: n/a
 
      04-07-2004
I have almost the same problem:

c_debug:rintf(int msg_debug_level, char * text, ...) {
...
sprintf(debug_text,text,&text+1);

or

va_start(marker,text);
sprintf(debug_text,text,marker);
va_end();

did not work!

Reprogramming sprintf seems stupid. What could I do??
I am using VC 6 - if this is important...

Thank's Markus



 
Reply With Quote
 
 
 
 
bartek
Guest
Posts: n/a
 
      04-07-2004
"markus_e" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) lkaboutprogramming.com:

> I have almost the same problem:
>
> c_debug:rintf(int msg_debug_level, char * text, ...) {
> ..
> sprintf(debug_text,text,&text+1);
>
> or
>
> va_start(marker,text);
> sprintf(debug_text,text,marker);
> va_end();
>
> did not work!
>
> Reprogramming sprintf seems stupid. What could I do??
> I am using VC 6 - if this is important...


You must have missed the vsprintf(char*, const char*, va_list) while
looking up the reference, I believe!

BTW. This question is more C than ++ related. Variable length argument
lists are evil in C++ as they break type safety, etc etc etc...

 
Reply With Quote
 
 
 
 
markus_e
Guest
Posts: n/a
 
      04-07-2004
>You must have missed the vsprintf(char*, const char*, va_list) while
>looking up the reference, I believe!


OK, I was new to va_arg and all this stuff (as I also think, it's not the
best behavior), so I did not know vsprinf - this hint helped a lot!

I will do my best to never use it again, but a debug:rintf is so
tempting...

Markus


 
Reply With Quote
 
markus_e
Guest
Posts: n/a
 
      04-07-2004
>You must have missed the vsprintf(char*, const char*, va_list) while
>looking up the reference, I believe!


OK, I was new to va_arg and all this stuff (as I also think, it's not the
best behavior), so I did not know vsprinf - this hint helped a lot!

I will do my best to never use it again, but a debug:rintf is so
tempting...

Markus


 
Reply With Quote
 
Andre Kostur
Guest
Posts: n/a
 
      04-07-2004
bartek <(E-Mail Removed)2.pl> wrote in
news:Xns94C47EA056FBFbartekdqwertyuiopo2p@153.19.2 51.200:

> BTW. This question is more C than ++ related. Variable length argument
> lists are evil in C++ as they break type safety, etc etc etc...


Evil, but still C++ related.....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a function that expects variable arguments from a functionwith variable arguments Navaneeth C Programming 4 11-20-2010 05:35 AM
Call again a variadic function (... variable number of arguments)with same arguments that its variadic wrapper moreau.steve@gmail.com C Programming 3 12-31-2008 07:13 AM
functions and arguments.length; passing unknown number of arguments oldyork90 Javascript 10 09-27-2008 03:05 AM
Variable number of arguments when calling a DLL function Vince C++ 3 11-10-2004 05:57 PM
variable number of arguments + function pointers Alex C++ 1 10-16-2003 10:31 PM



Advertisments