C++ – Is it possible to disable stderr in C++


I wrote a program for linux using libxml2 for html parsing. Although it does its job, the html parser writes lots of various errors to stderr. Is it possible to disable stderr at all (or redirect it to /dev/null while not having to run it with a redirecting shell script)? I can live with having to write my own errors to stdout, I just want to get rid of these errors.

Best Solution

Use freopen to redirect to dev/null:

freopen("/dev/null", "w", stderr);
Related Question