delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/20/06:15:49

From: "Phlip" <tegan AT deltanet DOT com>
Newsgroups: alt.comp.lang.learn.c-c++,comp.os.msdos.djgpp
Subject: Re: Instead of goto???
Date: Fri, 19 Dec 1997 08:59:28 -0800
Organization: RobRepMan Productions
Lines: 39
Message-ID: <67e8kt$fqr$1@news01.deltanet.com>
References: <348a15e5 DOT 826895 AT news DOT clear DOT net DOT nz> <01bd0a80$b482bb00$a47de3c7 AT merlyn> <3496C249 DOT 263D AT cs DOT com> <67crk0$kre$1 AT prefetch DOT san DOT rr DOT com>
NNTP-Posting-Host: anx-ana5050.deltanet.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Bill McNeely wrote:

>Just getting started in programming... and seeing goto in many of the
>samples of code that I have looked at from other programmers...I have yet
to
>find a better way to control display of information.
>
>For example I have used a goto statement and displayed some information
then
>used the getch() to hold the screen until key hit (I am aware of the
kbhit()
>command) for display screens, such as ego screens.  Any recommendations on
a
>better way to accomplish the same thing.

We can't see your code; there are many ways to write an input loop, and the
nature of the functions that collect input affect this.

Always use the best technology for the problem. Many techniques are better
than 'goto'.

You use it because you are thinking "control flow is here, but I want it to
be over there." Learn not to think this. Think "the statements between here
and there are all special, I need to control them as a group."

Use 'goto' (or 'return') to break out of a nested loop, and to avoid the
problem that 'break' exits both 3 different kinds of loops and 'switch'
blocks.

And a netiquette tip - when you quote another post, trim out irrelevant
material. Some folks pay by the minute to read this group!!

  --  Phlip
======= http://users.deltanet.com/~tegan/home.html =======
  --  "Java, the elegant simplicity of C++ and the
         blazing speed of Smalltalk" - Jan Steinman --



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019