How to create a printf wrapper
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: How to create a printf wrapper

  1. #1
    Join Date
    Jan 2003

    How to create a printf wrapper

    I am trying to create a function like:
    void my_printf(char *fmt, ...) which behaves like printf, except that it will also record all the argument passed in to a text file. Can anybody tell me how to do this?


  2. #2
    Join Date
    Sep 2003
    Forever Gone... For Now...
    My initial thought:
    Call my_printf just like you would call printf. Inside of my_printf, use va_list, va_start, va_arg, and va_end to extract the var args. Do what you will with them. Then, call vprintf with the va_list.

    You will know how many arguments were passed by the number of %'s (take %% into account, of course) in char* fmt...
    Thought for the day/week/month/year:
    Windows System Error 4006:
    Replication with a nonconfigured partner is not allowed.

  3. #3
    Join Date
    May 2000
    KY, USA
    Ciao, Andreas

    "Software is like sex, it's better when it's free." - Linus Torvalds

    Article(s): Allocators (STL) Function Objects (STL)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a survey!

HTML5 Development Center