why doesnt the compiler give an error when u haveCode:elsewhats the difference or there is none?Code:else;
why doesnt the compiler give an error when u haveCode:elsewhats the difference or there is none?Code:else;
When no one helps you out. Call google();
the compiler recognizes else as a keyword and expects either an opening { followed by one or more statement and then a closing } or else it assumes that the next statement is a single line to be controlled by the else. A statement is a line of code ending with a semicolon.
Therefore else by itself is incomplete and else followed immediately by a semicolon basically means do nothing.
Code:if(true) doThis(); else { doThat();//statement controlled by else } if(true) doThis(); else doThat();//statement controlled by else if(true) doThis(); else; //do nothing, since the statement controlled by else is empty
this should be perfectly legal
It sees the semicolon as a blank line, so it does nothing for the else.Code:if(condition) { do something } else ;
Kind of like
That does nothing forever.Code:while(1) ; // or while(1);
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c
it is, but it's a completely different concept... that has to do with the way statements are structured, not the "empty else" as my programming teacher used to call it
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT