[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppBreak
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppBreak
(C++) break
Keyword enabling you toExamples
End a for-loop
for(int i=0; i!=100; ++i) { if (i==69 && std::rand()%2==0) break; //Code }
- include <cstdlib>
End a while-loop
int i=0; while(1) { if (i==69 && std::rand()%2==1) { break; } ++i; }
- include <cstdlib>
End a switch-statement
int main() { switch(std::rand()%2) { case 0: std::cout << "Threw heads. " << std::endl; break; case 1: std::cout << "Threw tail. " << std::endl; break; } return 0; }
- include <cstdlib>
- include <iostream>
Code links
- ::, scope operator
- <<, stream out operator
- #include
- char
- cout
- endl
- int
- iostream
- main
- return
- scope operator, ::
- std
- stream out operator, <<
'break' links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
