www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/10/01/22:04:02

Message-ID: <3BB91231.34141548@yahoo.com>
From: CBFalconer <cbfalconer AT yahoo DOT com>
Organization: Ched Research
X-Mailer: Mozilla 4.75 [en] (Win98; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: while loops and for loops
References: <trhd37bspfqaac AT corp DOT supernews DOT com>
Lines: 47
Date: Tue, 02 Oct 2001 01:49:23 GMT
NNTP-Posting-Host: 12.90.174.139
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc04-news.ops.worldnet.att.net 1001987363 12.90.174.139 (Tue, 02 Oct 2001 01:49:23 GMT)
NNTP-Posting-Date: Tue, 02 Oct 2001 01:49:23 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

b279 wrote:
> 
> I can't get them to work correctly.
> 
> Problem 1:
> I have a for loop set up like this.
> 
> for (int i=1, i<100, i++)
>      my statements;

  for (int i = 1; i < 100; i++) {
     /* my statements */
  }

may work better.  Depending on compiler declaring i earlier may
work even better.

> But I get an error when I try to compile.
> 
> Error: parse error before ')'  - or something like that.  What does it mean?
> I have my loop set up correctly.

No you don't.

> Problem2:
> I have a while loop set up like this.
> 
> while(!kbhit())
>      my statements;

  while (!kbhit()) {
     /* my statements */
  }

has significant differences.

> 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.
> Is the loop set up correctly, and is kbhit() use it the right way?

kbhit() is non-standard and non-portable.

-- 
Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net)
   (Remove "XXXX" from reply address. yahoo works unmodified)
   mailto:uce AT ftc DOT gov  (for spambots to harvest)

- Raw text -


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