?
Solved

How to use GOTO ?

Posted on 2001-08-06
8
Medium Priority
?
280 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 75 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
Suggested Courses

762 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