Hi,
I would like to know an easy way to jump from one place to another in c++.
Best regards! Adam
Hi,
I would like to know an easy way to jump from one place to another in c++.
Best regards! Adam
Do you have a good (really, really good) reason to want to do so? One that isn't covered by the usual structures (if, while, for, etc.)?
You use flow controls such as:
do, while, if, else, for, switch, goto
Or functions.
Well I don't really know if it is the best thing to do maby you could do it without jumping. But I'm curious if there is some commands that will enable jumping in the code.
Yep. There sure are.
Example:
Code:int main(int argc, char **argv) { int i = 0; for_loop: if(i++ < argc) { puts(argv[i]); goto for_loop; } return 0; }
I showed you, now to repay me you can promise not to ever make me correct one out of your code.
thank you for showing me . But i still have some problems to create a for_loop: for exaple is there anything special you need to do? or just write the name like main: and then goto main; or?
Figured it out now . now i have another problem!!!
When i have the the jump command in a function but the header in the main function then you can't use the function to execute a jump. Is it possible to solve this ?
No. Are you an assembler language guy? Anything that requires you to jump into another function merits making whatever you are trying to jump to, to become its own function. I hope that made more sense than it did when I was reading it in my head -_-
Correctomundo. You can technically achieve that kind of jump if you know how to dupe your compiler into letting inline assembler correctly calculate where to jump. But that is such a crapshoot its not even worth trying. My point is simply that you could make the lines that follow your jump label a separate function.
okey, thanks.
by the way, is it possible to clear all the text in a program?
Which editor are you using?
system("cls"); Its insecure but about the only simple and portable way I can mention.