Thread: sprintf-like function

  1. #1
    Registered User
    Join Date
    Oct 2004
    Posts
    36

    sprintf-like function

    Hi guys,

    I need to write a wrapper for sprintf which accepts an arbitrary number of inputs (like sprintf does) and then pass these on to the wrapped sprintf function itself.

    How do I do this without using sprintf outside the function? Something like:

    Code:
    void do_somthing( const char *str, ...zero_or_more_inputs...){
      char buff[BUFFER_SIZE_MAX];
    
      // pass vars on to sprintf
      sprintf( buff, str, ...zero_or_more_inputs...);
    
      // use buffer
      use_buffer( buff );
    }
    Cheers,
    Pea

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    36
    Thanks!

    This was the eventual direct link: http://www.eskimo.com/~scs/C-faq/q15.5.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM