Here is the situation. I put each word from an input file into a string array. I want it to compute the size of each string (plus one to represent the space after) and then, when it reaches the maxWidth (whatever the user inputs), make it shift down to the next line. The only other rule is that the words should stop at one before the maxWidth (so maxWidth-1).
It runs mostly and does almost what I want it to. The only problem is sometimes, instead of starting a new line before the maxwidth limit is reached, it starts a new line after its reached, thus going over the number its supposed to.
I really don't know why though. I add the flush number before it outputs anything in the for loop and then tell it that if the flush is greater than or equal to maxWidth-1, to go to the next line and then start outputting again.