Redirect perror to file

Hi,

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?

1
2
// Redirect it
freopen("error.out","w",stderr);


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.