Solved

How to use GOTO ?

Posted on 2001-08-06
8
220 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand and use structures 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.

705 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

19 Experts available now in Live!

Get 1:1 Help Now