Re: printing error messages
- From: dj3vande@xxxxxxxxxxxxxxxxxxxxxxxxxxx
- Date: Fri, 30 May 2008 16:14:03 +0000 (UTC)
In article <a13081bb-7012-480f-85e2-de62db236222@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
gsa <hsggwk@xxxxxxxxx> wrote:
Hi,
I am new to C so please bear with my stupid questions. I am
trying to open a file to write, but the code complains that it is
unable to do so. How do I get C to print the reason it is failing?
Something like the $! function in perl. Thanks a lot for all your
help.
perror() may be what you're looking for.
I don't believe fopen is required to set errno when it fails, but on
every implementation I've encountered it does. (That may be influenced
by the fact that most of the implementations I've used are unixy, and I
think POSIX *does* require the underlying system calls to set errno.)
dave
--
Dave Vandervies dj3vande at eskimo dot com
I've been curious about what 'lingua franca' actually meant for a while, and
this seemed the perfect excuse to find out - and it appears to have worked.
comp.lang.c will never cease to amaze me. --Richard Heathfield
.
- References:
- printing error messages
- From: gsa
- printing error messages
- Prev by Date: Re: c compilation - gcc vs visual c
- Next by Date: Re: what is the output of this program?
- Previous by thread: printing error messages
- Next by thread: Re: printing error messages
- Index(es):