Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Help with my printf function

Tags:

c

printf

For debugging purposes I would like to have a printf_debug function that would function just like the standard printf function, but would only print if a #DEFINE DEBUG was true

I know I have to use varagrs (...) but I have no idea how to actually achieve that.

Thanks in advance.

like image 984
nunos Avatar asked Jul 13 '26 00:07

nunos


1 Answers

Easier to just #define it away. Something like this:

#ifdef DEBUG
#define printf_debug printf
#else
#define printf_debug while(0)printf
#endif

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!