Re: printing error messages



"Bill Cunningham" <nospam@xxxxxxxxx> writes:

"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.

Bill

I do not believe you. I would be interested in seeing this program that
suddenly magically worked when you change the code you call exit with.
.



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)