Reputation: 21
I want to modify ios_init.cc
so that cout
output will not be shown on the screen. I do not have option to recompile the binary.
I am trying in ios_base::Init::Init()
.
Does anyone have the knowledge as to what exactly I need to comment out.
Upvotes: 0
Views: 83
Reputation: 141860
You don't want to modify any Standard Library file!
You want to stop std::cout
updating the console. You can do this by redirecting std::cout
. The example to which I linked redirects to a file, but you can easily modify it to redirect to nowhere:
#include <iostream>
class scoped_cout_silencer
{
public:
scoped_cout_silencer()
:backup_(std::cout.rdbuf())
{
std::cout.rdbuf(NULL);
}
~scoped_cout_silencer()
{
std::cout.rdbuf(backup_);
}
private:
scoped_cout_silencer(const scoped_cout_silencer& copy);
scoped_cout_silencer& operator =(const scoped_cout_silencer& assign);
std::streambuf* backup_;
};
int main()
{
std::cout << "Now you see me." << std::endl;
{
scoped_cout_silencer silence;
std::cout << "Now you don't." << std::endl;
}
std::cout << "Now you see me." << std::endl;
}
Upvotes: 3