Albin Jose@suppo.fi to Programming · 1 year agoWhat will happen if we put a semi-colon after a for loop in C++?message-squaremessage-square17fedilinkarrow-up120arrow-down15
arrow-up115arrow-down1message-squareWhat will happen if we put a semi-colon after a for loop in C++?Albin Jose@suppo.fi to Programming · 1 year agomessage-square17fedilink
minus-squareplistig@feddit.delinkfedilinkarrow-up18·edit-21 year 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-squareoctoperson@sh.itjust.workslinkfedilinkarrow-up18·edit-21 year agoYour less thans got HTML-escaped into < and I spent embarrassingly long trying to figure out what pointer magic you were demonstrating
minus-squareplistig@feddit.delinkfedilinkarrow-up4·1 year agoYeah, both Voyager and the normal lemmy web client escape the less-than sign. I tried it twice on both clients.
minus-squareplistig@feddit.delinkfedilinkEnglisharrow-up6·1 year 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!