Redirect perror to file


I want to redirect the output of perror to a file. What is the best way to do that?
It writes to stderr. To redirect stderr to a file from a Bourne Shell derivative:
prog 2> errors.out
You mean I can use this statement in a C++ program?
wouldn't you want to do something like this?

// Redirect it

the main problem with this is that you can't 're-redirect' the stream back to the command line
You're asking the wrong question.

Use strerror to write the text to a buffer, then you do what you like with it.
interesting discussion ... i have no any idea...
Topic archived. No new replies allowed.