From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: rectification about switch ... such a big mistake Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: <1t98bsk2nkasbfviltn88lii1cngqf1pio@4ax.com> References: <88v09h$64n$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 52 X-Trace: +4AzTc6U3L+/8DZ9SVDimX4BUcwq0Cc5uKJpGwZw7lopRiYt5h6ons1TPrqkwpQtpOLdMJ+/ltfu!poWuFudafZriIXY4xRdj4PG/1ulYR7RNLF9ioUrvO+BUOLnvtXtRwKvliWcsS4Zx3ow5FhWSyBty!BzE6b0w= X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Wed, 23 Feb 2000 18:42:42 GMT Distribution: world Date: Wed, 23 Feb 2000 18:42:42 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Wed, 23 Feb 2000 18:10:00 GMT, "Andrew Jones" wrote: >[snip] > >> switch (charact) >> { >> case 'A': >> case 'M': >> check=1; >> }; >> } while ((test!=1)||(check==0)); > >[snip] > >Basically, even if A is pressed, your switch is >"falling through" to what's supposed to happen for 'M'. I'll illustrate with an example of case fallthrough from a hypothetical *craft clone: switch(kee) { case 'a': case 'A': clickMode = CLICKMODE_ATTACK; // attack an enemy or structure break; case 'b': case 'B': curMenu = BUILD_MENU; // basic structures break; case 'v': case 'V': curMenu = BUILD2_MENU; // advanced structures break; // /// // //// // //// //// // // // // // // // //// // //// // // default: PlaySound("DING.WAV"); // invalid break; } -- Damian Yerrick http://yerricde.tripod.com/ Comment on story ideas: http://home1.gte.net/frodo/quickjot.html AOL is sucks! Find out why: http://anti-aol.org/faqs/aas/ View full sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your .sig to prevent the spread of .sig viruses. http://www.mcafee.com/