From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Newbie Question: Index lookup coord. checking... Date: Mon, 28 Jul 1997 20:12:42 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 19 Message-ID: <33DCFD3A.6052@cs.com> References: <5rif6n$5v1 AT news DOT velocity DOT net> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp107.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Badman wrote: > > Hello, I have a simple question: Can you check coordinates for an index > lookup (so you don't get an error) and check that same index in the same > if() statement? [examples snipped] Yes; the order of logical processing in C requires that this be safe to do; the evaluation of a truth expression is halted once the truth or falsehood is known. But I would recommend handling the out of range errors separately; they may signify bugs in your program. -- --------------------------------------------------------------------- | John M. Aldrich | "It may be better to be a live jackal| | aka Fighteer I | than a dead lion, but it is better | | mailto:fighteer AT cs DOT com | still to be a live lion." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------