www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/01/15:05:12

Date: Mon, 01 Oct 2001 21:01:21 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "b279" <b279 AT inetone DOT net>
Message-Id: <557-Mon01Oct2001210121+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <trhd37bspfqaac@corp.supernews.com> (b279@inetone.net)
Subject: Re: while loops and for loops
References: <trhd37bspfqaac AT corp DOT supernews DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: "b279" <b279 AT inetone DOT net>
> Newsgroups: comp.os.msdos.djgpp
> Date: Mon, 1 Oct 2001 14:22:57 -0400
> 
> Problem 1:
> I have a for loop set up like this.
> 
> for (int i=1, i<100, i++)
>      my statements;

Wrong syntax.  Try this:

      for (int i = 1; i < 100; i++)
        {
	  your statements;
	}

This will only compile clean as a C++ program, for C programs, you
need to move the declaration of i outside the loop:

      int i;
      ...
      for (i = 1; i < 100; i++)
        {
	  your statements;
	}

> while(!kbhit())
>      my statements;
> 
> I would assume it would loop until a key is pressed, but I can push all the
> on the keyboard, but the while loop continues on.

This works for me.  Please post a complete short program which
exhibits this behavior.

- Raw text -


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