Hey guys,
why does the following get me an infinite loop?
size_t should be able to take the value of 0, so what seems to be the problem here?Code:for (size_t i = myString.length() - 2; i >= 0; --i) { cout << "test" << endl; }
Hey guys,
why does the following get me an infinite loop?
size_t should be able to take the value of 0, so what seems to be the problem here?Code:for (size_t i = myString.length() - 2; i >= 0; --i) { cout << "test" << endl; }
size_t is unsigned, so >= 0 is always TRUE.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Damn, how stupid was THAT?
Thanks.