Message-ID: <20001020133328.12262.qmail@web1102.mail.yahoo.com> Date: Fri, 20 Oct 2000 06:33:28 -0700 (PDT) From: A Scruffy Drummer Subject: RE: Array problems... To: djgpp AT delorie DOT com MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: djgpp AT delorie DOT com > Date: Thu, 19 Oct 2000 14:46:48 -0400 > From: "Johan" > > I have some problems with my program. I want to take > the numbers in array_a that are positive. 0 or above. > And put these in array_b and print them out. > Your problem is in the way it loops. You only need one "for" loop and the "j" should only get incremented after you decide to keep the value in "array_a". Also you only need to store the value of "array_a" in "array_b" and not add it (unless you have a reason for it). I stuck an additional check in the "for" loop so the value in "j" doesn't go past the limit "m". So here's how the fragment would look: int j = 0; for (int i = 0; i < n, j < m; i++) { if (array_a[i] >= 0) { array_b[j] = array_a[i]; j++; } } - jModule __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/