Questions tagged [goto]

In imperative programming, a "go to" statement is an unconditional jump instruction that changes the flow of control to the point of the program referenced by the "go to" statement.

1057 questions
-2
votes
1 answer

Android - How to use labeled statements

I am working on a project for which I have reverse engineered the code of other project. But, the code contains so much goto statements and a label with it. I tried to rearrange the code as per the labels used, but not getting the proper output. I…
Mitesh Shah
  • 192
  • 4
  • 16
-2
votes
2 answers

How do multiple goto labels work

Quick question: Let's say I am working in C code and I call a goto to go to a specific label, but I have multiple labels as such: goto A; A: //something B: //something else C: //something else When I goto A, will I also execute B…
Skorpius
  • 2,135
  • 2
  • 26
  • 31
-2
votes
1 answer

( goto was unexpected this time error

My code below is throwing errors. Please help. I am new to batch file scripts. It is showing syntax error and "goto was unexpected this time" error. My motive is to create a batch file which will accept a parameter from user. Based on that…
Meen
  • 119
  • 3
  • 15
-2
votes
2 answers

Why is this POD initialised with 0?

I was trying learn behaviour of POD in case of goto. Following is the program I used: #include void f(int i){ if (i < 10) goto jump1; int j; jump1: std::cout << j; } int main() { f(9); } Why is j…
Sumit Gera
  • 1,249
  • 4
  • 18
  • 34
-2
votes
4 answers

C++: How to decide the loop to continue to?

I have Nested do-while, while, and for loops. Is there a way to decide which loop to "continue" to? A variety of solutions would be great (not only goto..) Thank you! while (foo==true) // loop1 { do { for(int i=0; i
Farah
  • 2,469
  • 5
  • 31
  • 52
-2
votes
1 answer

Send control back to main.cc file in my c++ project from another souce file

Is it possible to send control from other file to main file using GOTO statement if yes please tell. if is it not possible please tell me another method. main.cc { outer: // label where I want to return callingfunc() …
Zubair
  • 1
  • 1
-2
votes
1 answer

Untangling Goto Statements (e.g. for replacement in Java)

Edit: I apologize for not explicating this. I am well aware that goto is not currently a functional part of the Java language. This question is not about trying to use goto in Java, it's about trying to not use it. Edit: And, while I do appreciate…
-2
votes
2 answers

How does switch behave as a goto?

I was trying to understand the working of switch in C, and after browsing through some of the answers on SO, I fumbled upon the following piece of answer on SO :- Basically, a switch acts like a goto to the appropriate label -- intervening…
Pratik Singhal
  • 6,283
  • 10
  • 55
  • 97
-2
votes
6 answers

Avoiding the use of Goto

All -- I am refactoring some older code and I am looking at ways to reduce (or if not eliminate it altogether) the use of the GoTo statement. I have a section of code as follows: public void GetData() { TryAgain: Foo foo =…
Mark Kram
  • 5,672
  • 7
  • 51
  • 70
-2
votes
2 answers

Realizing a goto statement

Actually I'm trying to study a code which is obfuscated with GOTO statements say.. private void fun() { if(somecondition) goto LABEL3; ... ... LABEL3: return; Exception e; e; if(true) goto LABEL3; else…
everlasto
  • 4,890
  • 4
  • 24
  • 31
-2
votes
3 answers

Use jmp_buf in multiple file

For clearly, please view my sample I have two files: main.cpp and myfunction.h This is main.cpp #include #include int main() { if ( ! setjmp(bufJum) ) { printf("1"); func(); } else { printf("2"); …
Phien
  • 148
  • 1
  • 14
-3
votes
1 answer

Goto function seems to loop the first half of the code

I normally don't create codes for myself, but today (or tonight, depending on your time zone) I created a simple calculator code which lets you enter multiple numbers, not just two items. This was a very ambitious idea, and so I got to work and then…
-3
votes
1 answer

how to use goto in a scanner function?

I tried to do a scanner function with goto to check if the vector with my dfa can be accepted, I'm having a problem with the logic, when I call the function the code starts to print in loop and it doesn't work. here is my code, i need help: #include…
-3
votes
1 answer

searching for the name of a variable linked to a cout! like a:cout c++

When I was searching for new information through source code in the internet, I saw someone used goto to a variable, and this variable was linked with a cout statement, the same as in std::cout. He wrote a:cout. Can you help me to find the name of…
-3
votes
1 answer

Goto command not working if run batch file from c: drive or desktop

I have small batch file to upgrade my program, if I run this batch file from any drive except C: drive it works correctly. I'm trying this command @ECHO OFF IF EXIST C:\TWA\DRV.TXT GOTO TST1 DIR *.EXE /P PAUSE :TST1 DIR ASHOK.ZIP PAUSE I'm…