Re: printing error messages



Bill Cunningham wrote:


"gsa" <hsggwk@xxxxxxxxx> wrote in message

news:dd7b86c4-554d-439d-ac90-a522770ce6ce@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I just stuck the error function call in the if block and it worked.

if((fp = fopen(stretchesFile, "w")) == NULL) {
error(1, errno, "could not open file %s", stretchesFile);
exit(1);
}

Thanks again for your help!!

For my 2 cents worth exit(1) isn't portable. Try
exit(EXIT_FAILURE) from
stdlib.h. For me it has made the difference between a working and non
working program.

exit(1) didn't work? What's your system and what exactly happened, i.e.,
what was the behaviour that made you conclude that exit(1) failed.

.



Relevant Pages

  • Re: printing error messages
    ... error(1, errno, "could not open file %s", stretchesFile); ... For my 2 cents worth exitisn't portable. ... between a working and non working program. ...
    (comp.lang.c)
  • Re: printing error messages
    ... error(1, errno, "could not open file %s", stretchesFile); ... For my 2 cents worth exitisn't portable. ... working program. ...
    (comp.lang.c)
  • Re: printing error messages
    ... error(1, errno, "could not open file %s", stretchesFile); ... For my 2 cents worth exitisn't portable. ... working program. ...
    (comp.lang.c)
  • Re: printing error messages
    ... error(1, errno, "could not open file %s", stretchesFile); ... For my 2 cents worth exitisn't portable. ... working program. ...
    (comp.lang.c)