delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/13/13:30:18

Message-Id: <199811082001.UAA16831@remus.clara.net>
From: "Arthur" <arfa AT clara DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: loop'ing
Date: Sun, 8 Nov 1998 20:00:56 -0000
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0
Importance: Normal
In-Reply-To: <000601be0b21$cb57ae60$a4feffc2@default>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

> I need a function for looping until 'esc' is press'ed!
> my code look like this:
>
> -----------------------------------------------
> again:
>
>  /* the game code */
>
>   if (key[KEY_ESC]) {
>       return 0;
>   }
>
> goto again
> -----------------------------------------------
>
> is there a better way of doing this?

Arrgh! Yuk, yuk!

A good peice of C code will _never_ have a goto statement in it. That's what
structure's all about :-)

This is much better:

------------------------------

do
{
	/ * the game code */
} while(!key[KEY_ESC]);

return 0;

------------------------------

James Arthur
jaa AT arfa DOT clara DOT net
ICQ#15054819


- Raw text -


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