10

The feeling when you didn't spot what the error was here:

int x = 0;
int y = 0;

for ( ; y < rows; y++) {
for ( ; x < cols; x++) {
//Dafuq, only does one line?!
}
}

Comments
  • 1
    I can't really see anything without looking at the arrays you are indexing through.

    I am guessing that cols and rows are reversed?
  • 12
    @deusprogrammer
    x doesn't get reset after the first iteration of the outer loop, so it stays equal to cols and the inner for loop's test fails every time.
  • 5
    Why set x and y before the loop?
  • 1
    Interesting coding style making scope that large.
  • 2
    Oh! God, how did I miss that?
  • 0
    @deusprogrammer that's why I rant at people who depend on heavy, formal code review to prevent defects. 😂
  • 0
    @deusprogrammer i really hoped someone else would miss it too!
  • 0
    @siksniraps On the question why one would declare the variable outside of the for loop, some C compilers will complain if you don't declare it before the for statement. But as to why I didn't set it in the for loop... Who knows, sometimes we're just stupid, aren't we?
  • 0
    @yamatoman I'd love to have someone like you review my code at my 05:30 busride when my spare 20 minutes of personal coding takes place 😁
  • 1
    @siljamicke tests, not manual review. 😂
Add Comment