Solved

How to use GOTO ?

Posted on 2001-08-06
8
233 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
  • 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
 
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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Can’t get the mobile email signature right?

Not having any luck when trying to create an email signature for mobile devices? Does the formatting keep messing up? Make sure you have great email signatures on all devices by using Exclaimer Cloud - Signatures for Office 365.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Directory does exist 19 144
Beginner Probleme with my IDE Code::Blocks C++ 5 233
Problem to show menu 5 87
Arduino EDI - Programming language 3 80
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…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
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.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now