#define problem

Dave Eisen dkeisen at leland.Stanford.EDU
Fri Jun 21 00:42:28 AEST 1991


In article <1991Jun20.051827.23428 at ux1.cso.uiuc.edu> J-Beauchamp at uiuc.edu writes:
>I have many occurences of 'printf(' which I would like to replace with
>'fprintf(stderr,' in my C program.  Is there a way to do this #define?
>
>#define printf( fprintf(sterr,
>

I agree with another poster that the best way to do this is with a 
text editor. Still, there is a solution along the lines of what you tried.

No, you can't define printf to be fprintf(stderr. But you can do the
following:

#define printf fprintf_stderr

int
fprintf_stderr (const char *fmt, ...)
{
   va_list args;
   int ret;

   va_start (args, fmt)
   ret = vfprintf (stderr, fmt, args);
   va_end (args);

   return ret;
}



More information about the Comp.lang.c mailing list