Hello,
Is there is a way within C to trap stdout and prevent it from displaying.

In my example I call a function that has the potential to print an error message to stdout. Is there a way to prevent messages to stdout from being displayed while my program calls on a function(trapping anything going to stdout). I know I could just modify the parameters to it to decide whether to display the error message or not, but modifying those would cause numerous other modifications since many other programs call upon this function.
I'm also just curious if its possible.

Any thoughts, alternatives?

How about dup stdout, close stdout handle, call the function, then finally restore the stdout handle. see man page for dup function

Be a part of the DaniWeb community

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