passing on printf()-style params?

This is a discussion on passing on printf()-style params? within the Game Programming forums, part of the General Programming Boards category; I'm using allegro to make a few troubleshooting functions. allegro_message() takes printf()-style parameters, right? So can I build a function ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    passing on printf()-style params?

    I'm using allegro to make a few troubleshooting functions. allegro_message() takes printf()-style parameters, right? So can I build a function that instead of working like this:
    Code:
    void message(string str) {
        allegro_message("%s",str.c_str());
    }
    works like this:
    Code:
    void message( ...printf()-style params...) {
        allegro_message( ...same params, all at once...);
    }
    This would be super slick because then the calls to message() would be much simpler. thx

    I realize that this has been answered in the past, I was just hoping that since there was only one big parameter and I was only passing it along, not messing around, this solution would be simpler.(?)
    Last edited by ichijoji; 07-16-2003 at 04:21 PM.
    Illusion and reality become impartiality and confidence.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You can also use vfprintf(), saving you a whole one line of code (bypassing vsprintf())
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 08:23 AM
  2. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 09:33 PM
  3. error in program????
    By SpEkTrE in forum C Programming
    Replies: 5
    Last Post: 11-24-2003, 05:16 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM

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