Re: Calls with a Variable Number of Arguments

Discussion in 'C++' started by markus_e, Apr 7, 2004.

  1. markus_e

    markus_e Guest

    I have almost the same problem:

    c_debug::printf(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
     
    markus_e, Apr 7, 2004
    #1
    1. Advertising

  2. markus_e

    bartek Guest

    "markus_e" <> wrote in
    news::

    > I have almost the same problem:
    >
    > c_debug::printf(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...
     
    bartek, Apr 7, 2004
    #2
    1. Advertising

  3. markus_e

    markus_e Guest

    >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::printf is so
    tempting...

    Markus
     
    markus_e, Apr 7, 2004
    #3
  4. markus_e

    markus_e Guest

    >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::printf is so
    tempting...

    Markus
     
    markus_e, Apr 7, 2004
    #4
  5. markus_e

    Andre Kostur Guest

    bartek <2.pl> wrote in
    news:Xns94C47EA056FBFbartekdqwertyuiopo2p@153.19.251.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..... :)
     
    Andre Kostur, Apr 7, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Analog_Guy
    Replies:
    1
    Views:
    517
    Mike Treseler
    Oct 5, 2005
  2. Honne Gowda A
    Replies:
    2
    Views:
    913
    Karl Heinz Buchegger
    Oct 31, 2003
  3. Replies:
    3
    Views:
    862
  4. Navaneeth
    Replies:
    4
    Views:
    573
    Kenny McCormack
    Nov 20, 2010
  5. oldyork90
    Replies:
    10
    Views:
    368
    Jorge
    Sep 27, 2008
Loading...

Share This Page