ok, everyone is telling me to use the goto() command, but every time I try it doesnt work. Can someone please explain how the goto() command works and what I do to make it work?
Thx
ok, everyone is telling me to use the goto() command, but every time I try it doesnt work. Can someone please explain how the goto() command works and what I do to make it work?
Thx
Do you mean the keyword goto (as in jump to another part of the program), or some screen positioning function to move the cursor to a point on the screen?
> but every time I try it doesnt work
Posting an example might help
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
goto needs a label like in basic.
#include <iostream.h>
void main()
{
cout << "\ntest";
goto label2;
label1:
cout << "\nlabel 1";
goto end;
label2:
cout << "\nlabel 2";
goto label1;
end:
cout << "\ndone.";
}
gotoxy(y,x) sets the x,y coords in the display.
Borland
#include <stdio.h>
#include <conio.h>
void main()
{
gotoxy(5,12), printf("row 12, col 5");
}
or is it col 12, row 5 hmmm
VC old versions
#include <graph.h>
#include <stdio.h>
void main()
{
_settextposition(5,12), printf(" row 5, col 12");
}
Last edited by ronin; 10-26-2001 at 01:46 PM.
I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P
Who is telling you to use GoTo? As a rule of thumb GoTo should NEVER be used. I strongly suggest that you change the design if you "need" to use the GoTo statement
GOTO is EVIL it is the the #1 way to get messy code
I never use goto; I always use functions. I was merely answering the question.
Last edited by ronin; 10-26-2001 at 10:24 PM.
I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P
Search the Windows and Game boards for goto and see what comes up. I know that you will find some interesting stuff.....I have been there.
C++ Is Powerful
I use C++
There fore I am Powerful
i'm teaching myself this C++ thing out of books and the like.
one guy says "avoid goto in al cases" the next says "it's there use it"
in the book C++ The Programing Language, on pg 137 Stroustrup says "The goto has few uses in general high-level programing..."
i think i'll stay away from it, if for any other reason to avoid the aperance of ignorance.
mr
goto is still the best way to exit from deeply nested loops. Its part of the language whether you like it or not. Unconditional jumps are common at assembler level yet no one moans about that!
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Stroustrup refers to the assembler using goto.
-------------------------------------------------------------
looks like your "free the weed" wishes are going well in the UK
Right on bro!!!
BUT downgrading cannabis to class c does not make it legal it just means you cant get arrested for possession of small amounts..... Exactly what is a small amount? I think the cops will still confiscate it ( and smoke it themselves if they are the coppers I know) if you are searched and they find it on you. Still at least its a small step in the right direction.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
goto isn't a function, and it does need a label.
Think out of the box! Open Source rules!
-Breach23