You can do text adventures without goto, do you have msn/skype? I can help you out. also check out the funcs in stdlib, there's one called exit (or abort, can't remember off the top of my head).
On 2/9/2011 11:41 AM, Kristoffer Gustafsson wrote:
Hi. Without goto it would be very hard to do text adventures. I don't think it can be done, or can it? Also, if I want my program to exit instead of continuing, how do I do?I mean for example, if I die in an adventure, I want to exit the program at that time, not continue the game./Kristoffer----- Original Message ----- From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>To: <programmingblind@xxxxxxxxxxxxx> Sent: Wednesday, February 09, 2011 7:28 PM Subject: Re: help with c++ if testThat produces all sorts of problems. jumping to the bottom of a loop is no problem with a goto, and it avoids issues with your exiting variable. it's also quicker, because you just jump to the bottom. otherwise you may break, but it's still going to have to do one more check (two, actually, depending on how the compiler does things) to see if exiting is false.On 2/9/2011 11:23 AM, Lex wrote: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 hereActually, 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-- Thanks, Ty __________View the list's information and change your settings at //www.freelists.org/list/programmingblind__________View the list's information and change your settings at //www.freelists.org/list/programmingblind
-- Thanks, Ty __________View the list's information and change your settings at //www.freelists.org/list/programmingblind