Trouble with increment in For loops

I can't understand why variable j doesn't increment its value in this for loop...

1
2
3
4
5
6
7
8
9
10
11
 int WinOrLose(unsigned int v[], const int size_v, const int n){

    for(int j = 0; j < size_v; j++){
        if(j < 3 && v[j] == n)
            return 0;
        else if(j == 3 && v[j] == n)
            return 1;
        else
            return -1;
    }
}
Look at the body of the loop. Every pass through it contains a return statement, so the function always returns during the first pass through the loop.
@dhayden ohhh right, thank you, I didn't see it...
Topic archived. No new replies allowed.