user3639557 user3639557 -4 years ago 256
C++ Question

how to disable cout output in the runtime?

I often use cout for debugging purpose in many different places in my code, and then I get frustrated and comment all of them manually. Is there a way to suppress cout output in the runtime? And more importantly, let's say I want to suppress all my cout outputs, but I still want to see 1 specific output (let's say the final output of the program) in the terminal. Is it possible to use an ""other way"" of printing to the terminal for showing the program output, and then when suppressing cout still see things that are printed using this ""other way""?

Answer Source

Don't use cout for debugging purposes, but define a different object (or function, or macro) that calls through to it, then you can disable that function or macro in one single place.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download