gXa's blog

By gXa, history, 9 years ago, In English

Why this compiles: Plz guide me on this:

int main() {

for(int i = 0; 0; i++) {

cout<<"H"; }

}

Can u elaborate the working of this code?

  • Vote: I like it
  • -12
  • Vote: I do not like it

»
9 years ago, # |
  Vote: I like it +17 Vote: I do not like it

Actually for loop will not do any iteration because 0 is the same as false. So since condition of loop is always false the loop will never do any iteration.