Sounds like Connect 4.
Something else seems to be at fault here, have you confirmed that the range of the loop variables, i and j, are correct? Hook us up with the code for the loops and the related...