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
-3
votes
4 answers

C++ if condition not checked after goto

I'm working on a simplish game (this isn't the whole code, just the bit that I'm having issues with) and I've run into this issue; After the condition is furfilled, it goes back to the start and it offers me to reenter the string, however, whatever…
Whealty_
  • 1
  • 1
-3
votes
3 answers

Is this a valid case for use of a 'goto' in Java

I am very much aware that 'goto' is a dirty word in the lexicon of most professional followers of structured programming. So I would ask how the following use of a 'goto' could be replaced. I'm writing a bridge bidding app. I ask the user "Who…
John of York
  • 93
  • 2
  • 12
-3
votes
2 answers

how to use goto in java

StartAgain: if(nit_arr.size() > 2) { System.out.println("size of list is more than 2"); j = prev.size()-2; k = prev.size()-3; if(nit_arr.get(j) == myChoice && nit_arr.get(k) == myChoice){ …
-3
votes
3 answers

Can't leave loop

I created small code in C to test something. I thought that if i write 0 I will receive output ABC. But I cannot leave the loop. Please help me. Thank you. #include #include int main() { int x; while(1) { printf("Enter…
Peter
  • 449
  • 1
  • 3
  • 13
-3
votes
8 answers

How to avoid GOTO in this code

This is a derivate of C, so please don't get all angry that it doesn't look correct. It is indeed correct in this implementation. I have this code: func() { if (handler_1()) goto good; if (handler_2()) goto good; if (handler_3()) goto…
MightyPork
  • 18,270
  • 10
  • 79
  • 133
-3
votes
4 answers

Issue with goto function in PHP

I am using a code snippet with goto function in PHP Here is my code function goto_test() { $a = 3; if($a == 3) { goto x; } else { if($a == 2) echo "Thuthmekri"; else…
Smruti Singh
  • 565
  • 1
  • 4
  • 14
-3
votes
2 answers

PHP goto control structure infinite execution

This seems to execute like an infinite loop. a: echo "Statement 1 \n"; b: echo "Statement 2 \n"; if(1 > 2) goto a; else goto b; But this works correctly. if(1 > 2) goto a; else goto b; a: echo "Statement 1 \n"; b: …
웃웃웃웃웃
  • 11,829
  • 15
  • 59
  • 91
-3
votes
4 answers

Javascript's equivalent to "goto"

I'm programming a basic click counter for my site on a hidden Easter egg page when I encountered a problem I never had when programming web before: Does Javascript have an equivalent to other programming languages goto. The code is below, if anyone…
Tristan
  • 27
  • 6
-3
votes
1 answer

How do I use "goto" in C++

When ı use goto in class in c++ ,I faced to that message,how can ı use goto in class c++? In member function `void note_system::student_no()': label 'stop' used but not defined`
Burak Deniz
  • 55
  • 1
  • 6
-3
votes
4 answers

Using goto from if to while

How can I stop using the goto here: if(true) { goto ln1; } DialogResult b=DialogResult.Yes; while(b==DialogResult.Yes){ //Stuff ln1: Function(); } Because using a goto from one scope to another is clearly not allowed.(It gives an…
anon
-3
votes
1 answer

C# Replace a goto statement with an if-else

I'm trying to replace this block of code with any other loop (I thought of while and do, but for some reason I didn't get the logic down entirely. repeat: ... if (condition) { goto repeat } else { ... } Can someone…
AzureFrost
  • 67
  • 2
  • 8
-4
votes
4 answers

Java C#'s goto equivalent

What I need is a way to go back to the top of the method is a special event is triggered, here's my code in C# public void SendRequest() { send: { var response = new RequestBuilder("https://google.com"). …
Peter Wave
  • 11
  • 3
-4
votes
3 answers

Efficiency of code. goto and function call

I just started learning c++. [MinGw, c++14]. If I want to transfer the control of a program to certain part of the code such that the control doesn't flow to any other part of the code. which is more efficient ? Using switch with goto statement and…
Sinister
  • 1
  • 6
-4
votes
1 answer

Why can't you end a while loop with a label?

Instead of writing while() { lbl: } You have to write while() { lbl:; } Why? It doesn't make any sort of sense to me. This is the case even if there was actual code in the loop
Toby Lam
  • 5
  • 1
-4
votes
2 answers

how GOTO works in c#

I have a for loop in c# winform and I want to start for loop again if i=7 The code looks like this : for (int i = 0; i < 10; i++) { if (i==7) { MessageBox.Show("you must start for loop again "); …
Vakho Akobia
  • 304
  • 1
  • 3
  • 13