I can't do a goto loop. man, i really suck.:( :( :( :( :( :( :( :( :( :(
Printable View
I can't do a goto loop. man, i really suck.:( :( :( :( :( :( :( :( :( :(
err.. a what loop?
so does goto loops ;)Quote:
I can't do a goto loop. man, i really suck
what do yo need it for anyway?
you're most definetly better off with for or while or something
similar,
if you REALLY want goto loops post some code and I'll help
/btq :)
my book says do this:
Code:#include <iostream>
using namespace std;
char n;
char pass;
char done;
char start;
int main()
{
start;
cout << "enter password: ";
cin >> pass;
if(pass = 'secret')
cout << "access granted, activating system 2342";
clrscr();
cout << "/nsystem error. Try again? ";
cin >> n;
if((n != 'y') goto done;
else
goto start;
done;
return 0;
}
well, try exchanging the semicolon after the labels to a colon..
that is instead of
start;
type
start:
haven't used em in ages though ;)
/btq
I think it should be
start:
not start;
But I wouldn't know, since I've never used goto before. Why? because it SUCKS.
i get this error:
line 2084: parse error before string constant.
Looking at the code, does it look like a 2048 line code?
Im thinking the way to solve it is to use the book as fire starter....
it was only $64.00
what book is still promoting goto?
teach youself c++ 6th Edition by al stevens
Avoid goto's until you *really* need them. Learn for and while for now.
Well, if this is code from a book.. wow.Quote:
Originally posted by Blizzarddog
start; //wrong label format
....
if(pass = 'secret') //:D
....
clrscr(); //no, no , no
.....
if((n != 'y') goto done; //notice the parenthesis
....
done; //hehe
That is a very good idea.Quote:
Originally posted by Blizzarddog
Im thinking the way to solve it is to use the book as fire starter....
i can do while. for... hmmm. ill have to learn those. :)
Yepo, its ashes.
Unfortunatly, it's not rare to find a book on the subject of programming with many inaccuracies to it... this book is definatly one of them!