Silent mode.

Hey, I've got a fairly lengthy program that I'm implementing a 'silent mode' option in (i.e when the program is run, it does what it's designed to do without outputting anything to console). The most obvious way I can think of is to set a flag (short int silent) and do an

Code:

if(silent != 0)

before every function that would output text. This isn't preferable as you can imagine, because that would end up being a lot of extra code that I have a feeling could be avoided.. can any of you offer up any suggestions as to how I could do this differently? Thanks in advanced =)

Well if you know when you want it to be "silent" and when you want it not to be then you may want to take a look at freopen() to reassign std output, aka stdout, to something other than the monitor.
Here is the description for freopen:

Code:

FILE *freopen(
const char *path,
const char *mode,
FILE *stream
);
Parameters
path
Path of new file.
mode
Type of access permitted.
stream
Pointer to FILE structure.
Return Value
Each of these functions returns a pointer to the newly opened
file. If an error occurs, the original file is closed and the function
returns a NULL pointer value.
Remarks
The freopen function closes the file currently associated with
stream and reassigns stream to the file specified by path.
_wfreopen is a wide-character version of _freopen; the path and
mode arguments to _wfreopen are wide-character strings.
_wfreopen and _freopen behave identically otherwise.