Your code is very difficult to read without nicely indented formatting. Please use code tags (use the "Code" button in the editor) in the future.

Your for loops have a stray semicolon after the parens that are causing behavior you do not expect (See the arrow below where I point out where the semicolon is in your for loops. Because of the semicolon, the code in the curly braces is not being executed as part of the for loop, instead it would be executed after the for loop.

for ( ... ) ; <--

Edit: Ack! I must have gone for a coffee break while I posted this, Amit posted an answer before mine posted.

Why are you using 2 or 3 in the first place? You ought not to use number literals (except 0 1 and -1), but fields. In this case you should use thelengthfield of the array

Chris Argueta
Greenhorn

Joined: Feb 26, 2012
Posts: 2

posted Feb 27, 2012 11:35:35

0

Thank you guys! That's exactly what was happening the semicolons were killing my for loop. I took them out and there everything went. I was my first time posting so my apologizes for the sloppy code posting. I appreciate the assistance its exactly what I needed. Thanks again!

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 44016

33

posted Feb 27, 2012 11:48:22

0

You would have been better to declare the counter variable as local to the loop. It doesn’t usually belong outside the loop, and in this case you would have suffered a compiler error.

I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com