I've got a library that is annoying me. When I command it to do what I need it to do, it spits out a bunch of text onto the screen that I don't need.
Is there a way to temporarily "mute" a console program, then re enable it later?

This is what I have found from Google:

std::streambuf* cout_sbuf = std::cout.rdbuf(); // save original sbuf
    std::ofstream   fout("/dev/null");
    std::cout.rdbuf(fout.rdbuf()); // redirect 'cout' to a 'fout'
  std::cout.rdbuf(cout_sbuf); // restore the original stream buffer

But that comes up with TONS of errors.

Any ideas? Thanks guys :)

Recommended Answers

All 4 Replies

Can you just clear the screen after the call?

I would but the problem is that all the stuff that gets printed out is really ugly and takes like ten seconds to finish

what's the external library? (if you don't mind)

it's Curl. Can't get it to invisibly download a file + disconnect from the file after its downloaded.

I can invisibly download the file, but when I try to use the info in the downloaded file later on in my program, it doesn't let me because it's still opened by Curl.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.