Albin Jose to Programming • 9 months agoWhat will happen if we put a semi-colon after a for loop in C++?message-square17fedilinkarrow-up120arrow-down15
arrow-up115arrow-down1message-squareWhat will happen if we put a semi-colon after a for loop in C++?Albin Jose to Programming • 9 months agomessage-square17fedilink
minus-square@[email protected]linkfedilink18•edit-29 months agoA semicolon ends a statement, and semicolon is a statement on its own. One that does nothing. That’s why you can write int i; for (i = 0; i ᐸ 3; i++); to set i = 3. You can use that pattern to find something in an iterator, etc. But I would prefer int i = 0; while (i ᐸ 3) { i++; } for readability.
minus-square@[email protected]linkfedilink18•edit-29 months agoYour less thans got HTML-escaped into < and I spent embarrassingly long trying to figure out what pointer magic you were demonstrating
minus-square@[email protected]linkfedilink4•9 months agoYeah, both Voyager and the normal lemmy web client escape the less-than sign. I tried it twice on both clients.
minus-square@[email protected]linkfedilinkEnglish6•9 months agoCanadian Aboriginal syllabics to the rescue!
A semicolon ends a statement, and semicolon is a statement on its own. One that does nothing. That’s why you can write
int i; for (i = 0; i ᐸ 3; i++);
to set
i = 3
. You can use that pattern to find something in an iterator, etc. But I would preferint i = 0; while (i ᐸ 3) { i++; }
for readability.
Your less thans got HTML-escaped into < and I spent embarrassingly long trying to figure out what pointer magic you were demonstrating
Yeah, both Voyager and the normal lemmy web client escape the less-than sign. I tried it twice on both clients.
deleted by creator
Canadian Aboriginal syllabics to the rescue!