473,383 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

break

Is there an equivalent C++ construct to Java's:

outer:
while (true) {
while (cond1) {
if (cond2) {
break outer;
}
}
}

Thanks
Jul 22 '05 #1
3 1954
Colin JN Breame wrote:
Is there an equivalent C++ construct to Java's:

outer:
while (true) {
while (cond1) {
if (cond2) {
break outer;
}
}
}


Well, there's goto:

while (1) {
while (cond1) {
if (cond2) {
goto AFTER_LOOP;
}
}
}
AFTER_LOOP:
// Goto takes us here.

Of course, one should be careful about using goto. See the FAQ:

http://www.eskimo.com/~scs/C-faq/q17.10.html

Some would say the case against goto applies equally to break (except in
switch blocks) and continue.

--
Russell Hanneken
rg********@pobox.com
Remove the 'g' from my address to send me mail.
Jul 22 '05 #2
Russell Hanneken wrote:

See the FAQ:

http://www.eskimo.com/~scs/C-faq/q17.10.html


Whoops, sorry, I thought I was posting in comp.lang.c. The C++ FAQ is here:

http://www.parashift.com/c++-faq-lite/

It doesn't say much about goto. But in this case, what the comp.lang.c FAQ
says applies just as well to C++ as it does to C.

--
Russell Hanneken
rg********@pobox.com
Remove the 'g' from my address to send me mail.
Jul 22 '05 #3
On Sat, 07 Feb 2004 01:25:53 +0000, Russell Hanneken wrote:
Russell Hanneken wrote:

See the FAQ:

http://www.eskimo.com/~scs/C-faq/q17.10.html


Whoops, sorry, I thought I was posting in comp.lang.c. The C++ FAQ is
here:

http://www.parashift.com/c++-faq-lite/

It doesn't say much about goto. But in this case, what the comp.lang.c
FAQ says applies just as well to C++ as it does to C.


Thanks for your help; I thought it might be something like that.

Colin

Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ann | last post by:
I have trouble sometimes figuring out where break and continue go to. Is there some easy way to figure it out, or a tool? TIA Ann
5
by: viza | last post by:
Hi! Suppose I have int i,j,k; for(i=0;i<I;++i){ /* loop 1 */ for(j=0;j<J;++j){ /* loop 2 */ for(k=0;k<K;++k){ /* loop 3 */ if(test){
25
by: chunhui_true | last post by:
In <<expert c>>I know the break in if wich is scoped in switch is break the switch,like: switch c case 1: if(b){ break; } ...... But like this: while(a){
5
by: tony collier | last post by:
To break out of a loop i have seen some people use RETURN instead of BREAK I have only seen RETURN used in functions. Does anyone know why RETURN is used instead of BREAK to kill loops?
55
by: Ennixo | last post by:
hi, do you know where i can find some ebooks or websites talking about C# optimisation ? for exemple, i just learned that ++i is faster than i++. i would like to know more about the things...
2
by: yyhhjj | last post by:
I created a test program to implement an iterator. First, I used 'yield break' in the iterator, it worked normally. Then, I simply used 'break' in the places of 'yield break', it still worked...
3
by: Barbara Alderton | last post by:
I recently wrote an ASP.NET app that used user controls. I produced a printer-friendly output form. One requirement was a pagebreak between one part of the form and another. I had no problem...
2
by: ichor | last post by:
hi i want to add a conditional break in my vb.net code. like we could in vb6. for example if the counter = 10 then break at that point. kindly let me know if thats possible in vb.net Ichor
26
by: Alexander Korsunsky | last post by:
Hi! I have some code that looks similar to this: -------------------------------------------- char array = "abcdefghij"; for (int i = 0; i < 10; i++) {
7
by: =?Utf-8?B?aXdlYg==?= | last post by:
Can we set page breaks in ASP Pages dynamically based on the data being populated? Akshay.
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.