vfprint as macro

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dipon
    New Member
    • Feb 2012
    • 1

    vfprint as macro

    #define PRINTF(...) \
    do { \
    fprintf(stderr, "MedicalRecorde r: " __VA_ARGS__); \
    fprintf(stderr, "\n"); \
    } while (0)


    #define DPRINTF(...) \
    do { \
    fprintf(stderr, "MedicalRecorde r: %s:%d: ", __FUNCTION__, __LINE__,); \
    fprintf(stderr, __VA_ARGS__); \
    fprintf(stderr, "\n"); \
    } while (0)


    i wanna use vfprintf instead of fprintf. so how to do that.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    What do you want to accomplish with vfprintf? Is there some functionality that you weren't able to achieve with these macros and you're hoping vfprintf will do it?

    It isn't obvious to me that you'll be able to effectively use vfprintf in a macro; I think you will need to write a function. Will this be your first time working with variable argument lists?

    Take a look at stdarg.h and vfprintf.

    Comment

    Working...