[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CBreak

(C) break

Keyword enabling you to
  • End a for-loop
  • End a  ?while-loop
  • End a switch-statement

Examples

End a for-loop

for(int i=0; i<100; ++i)
{
  if (i==69 && rand()%2==0) break;
  //Code
}


End a  ?while-loop

int i=0;
while(1) 
{
  if (i==69 && rand()%2==1) { break; }
  ++i;
}


End a switch-statement

  1. include <stdio.h>
int main() { switch(rand()%2) { case 0: printf("Threw heads."); break; case 1: printf("Threw tail."); break; } return 0; }


Code links

'break' links



last edited (November 6, 2006) by bilderbikkel, Number of views: 736, Current Rev: 1

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.