|
|
|
|
|
by pslam
4647 days ago
|
|
Simple transformation: for (unsigned i = strlen(s); i > 0; --i) {
if (s[i - 1] == '.') break;
}
Easy to see that s[i-1] does not underflow the array due to the loop invariant i>0. It's usually easy to convert signed iteration code to unsigned and when I see this, I can tell the author spent the time to consider what happens at the limits of their inputs. |
|