sprintf-like function

This is a discussion on sprintf-like function within the C Programming forums, part of the General Programming Boards category; Hi guys, I need to write a wrapper for sprintf which accepts an arbitrary number of inputs (like sprintf does) ...

  1. #1
    Pea
    Pea is offline
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Pea
    Pea is offline
    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, 10:03 PM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 01:28 PM
  4. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

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