| www.delorie.com/archives/browse.cgi | search |
| From: | "Dave Dutcher" <ddutcher AT symbology DOT com> |
| Newsgroups: | comp.os.msdos.djgpp,comp.os.msdos.programmer |
| Subject: | Re: Iteration vs. Recursion... |
| Date: | 27 Jul 1999 21:44:32 GMT |
| Organization: | StarNet Communications, Inc. |
| Lines: | 27 |
| Message-ID: | <01bed879$332ecc60$9154f6cc@symbology.symbology.com> |
| References: | <7n7s1h$ms6$1 AT autumn DOT news DOT rcn DOT net> <37978194 DOT 17661031 AT news DOT cso DOT uiuc DOT edu> |
| NNTP-Posting-Host: | 204.246.84.145 |
| X-Trace: | blackice.winternet.com 933111872 20772 204.246.84.145 (27 Jul 1999 21:44:32 GMT) |
| X-Complaints-To: | abuse AT winternet DOT com |
| NNTP-Posting-Date: | 27 Jul 1999 21:44:32 GMT |
| X-Newsreader: | Microsoft Internet News 4.70.1155 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
I think the problem with the original code was calling getch() in every if
statement, and previous responses have explained how to fix the problem.
But I couldn't help noticing that a lot of people suggested switch
statements. I wonder if people suggested a switch statement because the
orignal poster was looking to increase his speed, or did they suggest it
because they think switch statements are more readable? I am wondering
because, from what I have heard, switch statements are no faster than a
whole bunch of if statements.
Dave.
Peter Johnson <locke AT mcs DOT net> wrote in article
<37978194 DOT 17661031 AT news DOT cso DOT uiuc DOT edu>...
> Do something like the following:
>
> switch(getch()) {
> case x: run_program1();
> break;
> case y: run_program2();
> break;
> ...
> }
>
> Read up on switch statements in your favorite C reference book :).
>
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |