delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/06/08:00:38

From: "A. Sinan Unur" <sinan DOT unur AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: For loop problem
Date: Mon, 06 Apr 1998 07:47:34 -0400
Organization: Cornell University (http://www.cornell.edu/)
Lines: 46
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <3528C0D5.35C5B4FB@cornell.edu>
References: <3527FEA6 DOT 54FA AT vegas DOT infi DOT net> <3528041A DOT 36E2 AT vegas DOT infi DOT net>
NNTP-Posting-Host: cu-dialup-1117.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Simz wrote:
> 
> Simz wrote:
> >
> > When ever I try to use a for loop in DJGPP with a char (or any type 
> > for that matter), the loop never stops when I try to loop to the max 
> > value
> > that type can hold. For example
> >
> > unsigned char index = 0;
> > unsigned char array[256];
> > for (index = 0; index < 256; index++)
> >         array[index] = index;
> >
> > This loop never stops, I've even tried..
> > for (index = 0; index <= 255; index++)
> > for (index = 0; index < 256; ++index)
> > for (index = 0; index <= 255; ++index)
> >
> > And I need all 256 iterations for my programs to work.
> > Any sugestions?
> 
>  Besides using an integer.

why not? you could always do:

int main(void)
{
 unsigned char i;
 unsigned char answer[256];

 for( i = 0 ; i < 255 ; i++)
   answer[i] = 42;
 answer[i] = 42;
}

i just think it is error-prone, and meaningless. but, then, you might
have a special reason.
-- 
----------------------------------------------------------------------
A. Sinan Unur
Department of Policy Analysis and Management, College of Human Ecology,
Cornell University, Ithaca, NY 14853, USA

mailto:sinan DOT unur AT cornell DOT edu
http://www.people.cornell.edu/pages/asu1/

- Raw text -


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