Re: help with c++ if test
- From: Lex <lex@xxxxxxxxxx>
- To: programmingblind@xxxxxxxxxxxxx
- Date: Wed, 09 Feb 2011 20:23:15 +0200
09.02.2011 20:17, Littlefield, Tyler пишет:
really really highly recommend you avoid goto. This isn't basic, and
they're not very useful except for in some odd cases, far and few
between. Such as jumping out of two nested loops like so:
int i, j;
for (i = 0; i < 100; i++)
{
for (j = 0; j < 100; j++)
{
if (i+j == 100)
goto botttom;
}
}
bottom:
//do something here
Actually, effect you're trying to achieve is more correctly by the
conditional variable (at least in terms of procedural programming):
bool exiting=false;
for (i = 0; i < 100 && !exiting; i++)
{
for (j = 0; j < 100 && !exiting; j++)
{
if (i+j == 100)
exiting=true;
}
}
or may be even
for (j = 0; j < 100; j++)
{
if (i+j == 100)
{
exiting=true;
break;
}
}
}
Lex
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind
Other related posts:
- » help with c++ if test- Kristoffer Gustafsson
- » Re: help with c++ if test- qubit
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test - Lex
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Lex
- » Re: help with c++ if test- Kristoffer Gustafsson
- » RE: help with c++ if test- Sina Bahram
- » RE: help with c++ if test- Ken Perry
- » Re: help with c++ if test- Kristoffer Gustafsson
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Sina Bahram
- » RE: help with c++ if test- Ken Perry
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Kristoffer Gustafsson
- » RE: help with c++ if test- Ken Perry
- » Re: help with c++ if test- Christopher
- » RE: help with c++ if test- Ken Perry
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Sina Bahram
- » RE: help with c++ if test- Sina Bahram
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Kristoffer Gustafsson
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Ken Perry
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Littlefield, Tyler
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Kristoffer Gustafsson
- » Re: help with c++ if test- Littlefield, Tyler
- » Re: help with c++ if test- Lex
- » RE: help with c++ if test- Sina Bahram
- » Re: help with c++ if test- Alex Midence