Is it possible to replace printf with userdefined function or is it possible to create function similar like printf
+1
A:
Sure, you can define variadic functions (the technical name for functions with a variable number of arguments, like printf
) -- the URL I've pointed to is one reference for how to do it.
Alex Martelli
2010-05-04 05:41:55
A:
Go look at the source for printf, or _VFPRINTF_R in this case, and see if that is something you want to write.
drawnonward
2010-05-04 05:49:33
A:
If you want to use your own version of printf, you can do something like this once it is defined
/*
* Make printfs use your new printf
*/
#define printf my_printf
and define your my_printf
however you like
As for how printf could be written, have a look at The C Programming Language by K&R. It has a section on how printf
function might be written.
hhafez
2010-05-04 05:51:01