[prog] C programming - capturing information sent to stdout

Mary mary-linuxchix at puzzling.org
Thu Jul 14 11:18:09 EST 2005


On Thu, Jul 14, 2005, Sue Stones wrote:
> Thanks for your explanation Mary, that was great.  I was wondering about 
> things like replacing all the error checking around things like opening 
> a file ... (open file, check if its open, in not print an error message, 
> and then exit(1) ).
> It would certainly make that code more readable. 

It would (so does a language with exceptions sometimes, because you can
just catch IOException or whatever at a single point). However of course
in many programs a file error should not be fatal (ie OpenOffice
shouldn't *crash* if you tell it to open a file that doesn't exist or
which is unreadable, it should just give you an error message).

Robust programs in production would never have asserts that fire under
conditions they expect to be reached during normal operation (which
includes expected errors). Debugging is a different ballgame :)

-Mary


More information about the Programming mailing list