how to get errors associated with studio.h functions

Started by
3 comments, last by SiCrane 18 years, 1 month ago
I'm having a problem with fopen not opening files that actually exist on the hard drive. So I'm trying to figure out how to get the associated error. I tried using perror("c:/output.txt") but it doesn't create the file with the errors. How can I capture the output or at least redirect stderr to a file?
Author Freeworld3Dhttp://www.freeworld3d.org
Advertisement
Since "\" can be used as a special character in C-style languages, you have to use the escape character "\\" instead. This should work the same for "/", I think.
www.aidanwalsh(.net)(.info)
'/' is just '/'. As you said, \ is the escape sequence onde, so it needs \\ to show you wanna print \, not the sequence.

You want to be able to differ from can't open existing file error and there is no file to open error? Because using "w" or "a" modes (with modifiers also) will created a new file, if there isn't one with that name.
Okay, but the real question is how to direct the errors of the standard library to a file. Do you just use perror or is there some other method?
Author Freeworld3Dhttp://www.freeworld3d.org
To direct stderr to a file you can use shell redirection. For example, when running your program with sh based shells you can use pp 2> file to direct stderr to the file file. Programmatically you can use freopen() to direct stderr to a file within your program.

This topic is closed to new replies.

Advertisement