D
D¿ejm
Hello,
We have a code with lot of printfs. Now I would like to introduce special
mode, in which only special messages are displayed and all other are hidden.
No macros or replacements please. I'm looking for good looking in one place
solution .
Disabling printf is easy:
fclose( stdout );
But then I can't output anything.
I thought about duplicating handle, and opening my own output. But then all
the printfs are visible again somehow:
int fd = dup( _fileno( stdout ) );
fclose( stdout );
printf( "Should NOT be visible. It is not. Good.\n" );
FILE * specialOutput = _fdopen( fd, "w" );
fprintf( specialOutput, "Should be visible. It is. Good.\n" );
printf( "Should NOT be visible, but it is. Bad.\n" );
Any other ideas how to do this ?
PS. There are also cout used. But this probably will do the trick:
cout.clear( ios::badbit );
Dz
We have a code with lot of printfs. Now I would like to introduce special
mode, in which only special messages are displayed and all other are hidden.
No macros or replacements please. I'm looking for good looking in one place
solution .
Disabling printf is easy:
fclose( stdout );
But then I can't output anything.
I thought about duplicating handle, and opening my own output. But then all
the printfs are visible again somehow:
int fd = dup( _fileno( stdout ) );
fclose( stdout );
printf( "Should NOT be visible. It is not. Good.\n" );
FILE * specialOutput = _fdopen( fd, "w" );
fprintf( specialOutput, "Should be visible. It is. Good.\n" );
printf( "Should NOT be visible, but it is. Bad.\n" );
Any other ideas how to do this ?
PS. There are also cout used. But this probably will do the trick:
cout.clear( ios::badbit );
Dz