473,836 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

continue with switch

'continue' within switch actually associated with the outer 'while'
loop. Is this behavior protable?

int ch = '\n';
while (true) {
switch(ch) {
case '\n': cout << "test"; continue;
}
}

the above loop executed endlessly in "gcc version 2.96 20000731 (Red
Hat Linux 7.3 2.96-110)".

May 12 '06
25 18399
v4vijayakumar wrote:
break/continue inside loop means
break-the-loop/continue-next-iteration, but inside switch (as it is not
associated with any looping) both could mean same thing, that is
execute-the-statement-next-to-switch.
No, a continue has no meaning in a switch.
am directly posting from google groups. can you please let me know,
what tool people generally use to read/post to groups. TIA.


Almost and news client is better than Google, even Outlook Express,
although personally I use Thundirbird, I've also used Agent and
Sylpheed. Ask you ISP for details of your news server or search for a
free or pay for server.

However, when posting using Google is *is* possible to provide context,
so please do so. See the information about Google at and linked from
http://clc-wiki.net/wiki/Intro_to_clc
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 12 '06 #11
pete wrote:
Bart Rider wrote:
v4vijayakum ar wrote:
'continue' within switch actually associated with the outer 'while'
loop. Is this behavior protable?

[...skip...]
/* BEGIN new.c */

#include <stdio.h>

int main(void)
{
int ch = 'a';
int i = 0;

while (1) {
++i;
switch(ch) {
case 'a': printf("i=%d, a\n",i); ch='b'; continue; break;
case 'b': printf("i=%d, b\n",i); ch='c'; continue;
default: return 0;
}
}
return 0;
}

/* END new.c */


Was a little bit misleaded by my code.
No I see clear. Thanks for opening my eyes.

Bart
May 12 '06 #12
Bart Rider wrote:
Richard Bos wrote:
"v4vijayaku mar" <v4***********@ yahoo.com> wrote:

'continue' within switch actually associated with the outer 'while'
loop. Is this behavior protable?

int ch = '\n';
while (true) {
switch(ch) {
case '\n': cout << "test"; continue;
}
}

I have no idea if it's portable under C++, which is what your code
actually is. In this newsgroup we discuss ISO C, and yes, in that
language any continue statements do not apply to a switch statement, but
to the continue's closest surrounding loop statement, if there is any.

Richard


really?
Any break inside a switch statement is actually assigned to the
switch statement (it leaves the choice statement switch and continues
with the first statement after switch) and not for any surrounding loop.
The same applies to continue IMHO.


Nope. continue only applies to loops.
May 12 '06 #13
v4vijayakumar wrote:
.... snip ...
am directly posting from google groups. can you please let me know,
what tool people generally use to read/post to groups. TIA.


Google groups is a very poor interface to Usenet. You can use the
methods described below in my sig. However you would be well
advised to install a real newsreader (such as Thunderbird from
mozilla.org) and access news directly through your ISP and a
newsserver. Most ISPs supply a newserver.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Also see <http://www.safalra.com/special/googlegroupsrep ly/>

May 12 '06 #14
On 2006-05-12, CBFalconer <cb********@yah oo.com> wrote:
v4vijayakumar wrote:

... snip ...

am directly posting from google groups. can you please let me know,
what tool people generally use to read/post to groups. TIA.


Google groups is a very poor interface to Usenet. You can use the
methods described below in my sig. However you would be well
advised to install a real newsreader (such as Thunderbird from
mozilla.org) and access news directly through your ISP and a
newsserver. Most ISPs supply a newserver.


Just out of curiousity, have you ever had problems with Thunderbird
locking up? Whenever a large batch of messages came in, the
program would stop working permanently and require me to delete all
my mail files. I was using FC5.

Now I just use slrn, and I highly recommend it. The only issue I
have encountered is that I need to do my own line wrapping.
May 12 '06 #15
CBFalconer wrote:
v4vijayakumar wrote:

... snip ...

am directly posting from google groups. can you please let me know,
what tool people generally use to read/post to groups. TIA.


Google groups is a very poor interface to Usenet. You can use the
methods described below in my sig. However you would be well
advised to install a real newsreader (such as Thunderbird from
mozilla.org) and access news directly through your ISP and a
newsserver. Most ISPs supply a newserver.


Many ISPs these days have dropped usenet access, notably AOL. Mostly
dial-ups (in the US) have gotten rid of it, but some broadband
providers. If the OP is unable to get it from the ISP, then either a
free news service (I don't personally know of any) or a for-pay one
will be needed. I use news.individual .net, it costs 10 euro per year,
about $13 US.

Brian
May 12 '06 #16
On 2006-05-12, Default User <de***********@ yahoo.com> wrote:
CBFalconer wrote:
v4vijayakumar wrote:
>

... snip ...
>
> am directly posting from google groups. can you please let me know,
> what tool people generally use to read/post to groups. TIA.


Google groups is a very poor interface to Usenet. You can use the
methods described below in my sig. However you would be well
advised to install a real newsreader (such as Thunderbird from
mozilla.org) and access news directly through your ISP and a
newsserver. Most ISPs supply a newserver.


Many ISPs these days have dropped usenet access, notably AOL. Mostly
dial-ups (in the US) have gotten rid of it, but some broadband
providers. If the OP is unable to get it from the ISP, then either a
free news service (I don't personally know of any) or a for-pay one
will be needed. I use news.individual .net, it costs 10 euro per year,
about $13 US.


I can't imagine anyone on c.l.c who uses AOL, but I've been
surprised before.
May 12 '06 #17
Default User wrote:
CBFalconer wrote:
v4vijayakumar wrote:
... snip ...
am directly posting from google groups. can you please let me know,
what tool people generally use to read/post to groups. TIA.

Google groups is a very poor interface to Usenet. You can use the
methods described below in my sig. However you would be well
advised to install a real newsreader (such as Thunderbird from
mozilla.org) and access news directly through your ISP and a
newsserver. Most ISPs supply a newserver.


Many ISPs these days have dropped usenet access, notably AOL. Mostly
dial-ups (in the US) have gotten rid of it, but some broadband
providers. If the OP is unable to get it from the ISP, then either a
free news service (I don't personally know of any) or a for-pay one
will be needed. I use news.individual .net, it costs 10 euro per year,
about $13 US.


There is a news group about free news servers...

Also I know of a couple of free servers.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc

Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
May 12 '06 #18
Bart Rider wrote:
Any break inside a switch statement is actually assigned to the
switch statement (it leaves the choice statement switch and continues
with the first statement after switch) and not for any surrounding loop.
The same applies to continue IMHO.


did you try it?

void foo(int x) {
switch (x) {
case 0: continue;
case 1: break;
}
}

t.c: In function 'foo':
t.c:3: error: continue statement not within a loop

May 12 '06 #19
Bart Rider <ca*******@kill amail.com> writes:
[...]
Any break inside a switch statement is actually assigned to the
switch statement (it leaves the choice statement switch and continues
with the first statement after switch) and not for any surrounding
loop. The same applies to continue IMHO.


I'm afraid that your opinion, humble or otherwise, has no bearing on
the question.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 12 '06 #20

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

Similar topics

2
2699
by: Michael Satterwhite | last post by:
I *MUST* be overlooking something obvious. Consider the following code: foreach($_POST as $key=>$value) { print "$key=>$value<br />"; if(! empty($value)) { switch($key) { case "Submit": case "keyList": case "curKey": print "Matched exception<br />";
5
33719
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){
4
4671
by: Christopher Benson-Manica | last post by:
Given the following snippet, int i; for( i=0 ; i < 10 ; i++ ) { switch( i ) { case 0: case 1: continue; /* NB */ default: /* do something */
1
7845
by: jerico | last post by:
Hi.Could any one explain me the following program: int main() { char input="SWILTECH1\1\1"; int i,c; for(i=0;(c=input)!='\0';i++) { switch(c) {
13
2016
by: xz | last post by:
What if I want the following: vector<intv; // v is loaded by push_back() switch( v.size() ) { case 2: //do something
36
2682
by: mdh | last post by:
May I ask the group this somewhat non-focused question....having now seen "continue" used in some of the solutions I have worked on. ( Ex 7-4 solution by Tondo and Gimpel comes to mind) Is there a good principle/s for the good usage of "continue"...or...do any of the regular/irregular contributors have a "favorite" way in which it is particularly useful. Thanks as usual.
0
9665
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10835
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10541
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5645
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4007
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3108
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.