Solved

How to use GOTO ?

Posted on 2001-08-06
8
261 Views
Last Modified: 2010-04-15
Hello there. Could anyone show me an example how i can use the GOTO in C ? Thanks.
0
Comment
Question by:andoryu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 2

Accepted Solution

by:
Lockias earned 25 total points
ID: 6356406
int main()
{
   /*  Some code here */

   GOTO MyLabel;

   /* Some code here */

   MyLabel:

   /* Some code here */

   return 0;
}

~Lockias
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6356409
Sorry,
  "GOTO" should be "goto"

~Lockias
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6356421
However,
  I must say you should almost never use goto in C unless you are breaking out of some horrible nested loop or something like that.

~Lockias
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Expert Comment

by:ahoffmann
ID: 6356460
Lockias, you *almost ever* have to use goto even in C when programming something like stated loops, finite state machine, etc.
(-:I'm picky, sometimes;-))
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6356490
Isn't that what I just said?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6356515
ok, if i substitute "horrible nested loop" by "mealy machine" for example ;-)
Don't feel offended.
andoryu, sorry for chatting ...
0
 

Author Comment

by:andoryu
ID: 6357910
Thanks for everything guys. I just wanted to confirm because I can't find any examples related to GOTO in C earlier.
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6357930
Why is that only worth a B??
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question