Sign in to follow this  
soconne

how to get errors associated with studio.h functions

Recommended Posts

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?

Share this post


Link to post
Share on other sites
'/' 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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this