Date: Mon, 01 Oct 2001 21:01:21 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: "b279" 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: (b279@inetone.net) Subject: Re: while loops and for loops References: 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 Precedence: bulk > From: "b279" > 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.