delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/22/15:25:49

Date: Fri, 22 Sep 1995 15:07:42 -0400
From: byers AT cs DOT utk DOT edu
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Problem

  I have used GCC for about 4 years on a UNIX machine.  I just installed djgpp
on my DOS machine.  I started writing a program and in one of my functions,
I have a series of statements like:

	i = 0
	while(i < size)
	{
	  A[i] = pick_random_number();
	  if(C[(A[i])] == USED)
	     continue;
	  else {
	     C[(A[i])] = USED;
	     ++i;
	  }
	}

C[] is of size 45 or so.  This is simply supposed to load an array A with
unique random numbers.  C is used to mark a number USED or not.  C and A are
both initialized before the code is executed.  The problem is when I print out
the values for i, it goes 0,2,3,4,5,...,size.  It completely skips i == 1.
When I take the next to the last line of code out (C[A[i]] = USED), it works
fine.  I don't see anything that can be wrong.  I have checked the code over
and over.  Is there anything that I need to change in the compiler?  Is there
something I am not seeing?  It seems like i is incremented by two at one time
rather than just one.  I changed ++i to i = i + 1 which does not help.  Any
suggestions?

Thank you,
Stephen Byers

- Raw text -


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