RE: help with c++ if test
- From: "Sina Bahram" <sbahram@xxxxxxxxx>
- To: <programmingblind@xxxxxxxxxxxxx>
- Date: Wed, 9 Feb 2011 13:50:25 -0500
tyler, this is a horrible example of goto, my friend.
That's what break is for.
Take care,
Sina
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Littlefield, Tyler
Sent: Wednesday, February 09, 2011 1:17 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: help with c++ if test
I 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
if you want to compare strings, do something like this:
if (input == "north")
{
GoNorth();
}
else if (input == "south")
...
else ...
On 2/9/2011 10:52 AM, Kristoffer Gustafsson wrote:
Hi.
I'm writing if tests in c++ with the goto command.
I want to do text games and I'm using these commands for that.
But it doesn't work, so I must do something wrong.
Can you give me an example how this is done with a string please?
/Kristoffer
--
Thanks,
Ty
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