[prog] C programming - capturing information sent to stdout

Conor Daly conor.daly-linuxchix at cod.homelinux.org
Thu Jul 14 09:51:52 EST 2005


On Wed, Jul 13, 2005 at 08:59:16AM +1000 or so it is rumoured hereabouts, 
Sue Stones thought:
> Kathryn Hogg wrote:
> 
> >  assert(newfd == 1);
> 
> The assert is a new thing to me, so I read up on it of course.  Are 
> there stylistic boundaries on when and where it should be used?

Basically, assert does something like:

if(! foo) {
  panic;
}

assert does a test.  If the test fails, the program halts with a hopefully
useful error message.  It should be used liberally for debugging anywhere
in your code where you expect a variable to be a certain value.

That's not very well explained at all...

Conor
-- 
Conor Daly <conor.daly at oceanfree.net>

Domestic Sysadmin :-)
---------------------
Hobbiton.cod.ie
 00:48:35  up 7 days,  3:42,  1 user,  load average: 0.00, 0.01, 0.00


More information about the Programming mailing list