Thread: Goto Label

  1. #1

    Question Goto Label

    I know I deserve to be shot for even mentioning this but is it possible to have a label in one source file in a project and jump to it from another source file?

    also in a concole window, is the a command that will close the window?

  2. #2

    Re: Goto Label

    Originally posted by unanimous
    I know I deserve to be shot for even mentioning this but is it possible to have a label in one source file in a project and jump to it from another source file?

    also in a concole window, is the a command that will close the window?
    Well, I dunno about the goto thing but to close the window (I guess you mean quit the program) you can either:

    [1] Call exit()
    [2] Type return 0; in the main() function.
    -Save the whales. Collect the whole set.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > is it possible to have a label in one source file in a project and jump to it from another source file?
    No.

    If you really need to, use setjmp() and longjmp()
    Same disclaimers about abuse of these are the same as for goto, but more so.

  4. #4

    Question setjmp() longjmp() Call EXIT

    How do I use setjmp() or longjmp() to goto a label in another source file? And, how do I Call Exit?

  5. #5

    Question Manual

    Where can I get this manual?

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Just about ANYWHERE. Put in at least a little more effort than "Point me in the right direction, give me a sharp push, and make my feet walk right".

    -Prelude
    My best code is written with the delete key.

  7. #7
    STFW
    -Save the whales. Collect the whole set.

  8. #8
    bobish
    Guest
    I noticed u have MVC++ 6 this means you also have msdn, look at that. You have Dev C++ 4 also, when you compile programs with that the console quits automaticaly once main ends, this is also true with msvc++ 6 if your running in debug mode. Oh and the thing about goto, try it, if it works it works, if it doesn't it doesn't. Still never use goto, praticularly jumping from one function to another, although it seems usefull it will make your code really hard to follow.

  9. #9
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >Still never use goto, praticularly jumping from one function to another
    This can't be done anyway, goto is restricted to the function that the label is defined in. Despite what some people think, goto is not a nightmarish construct that lets you go anywhere in the program without restriction.

    -Prelude
    My best code is written with the delete key.

  10. #10
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    >>Despite what some people think, goto is not a nightmarish construct that lets you go anywhere in the program without restriction.

    AHHH, Music to my ears, atlast there is somebody else who thinks the way i do about GOTO
    -

  11. #11
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    yes, nightmarish constructs are uninitialized pointers and other programmer follies... goto has defined behavior, which is A-okay...
    hasafraggin shizigishin oppashigger...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. temperature sensors
    By danko in forum C Programming
    Replies: 22
    Last Post: 07-10-2007, 07:26 PM
  2. Label within a label?
    By Manaxter in forum C# Programming
    Replies: 0
    Last Post: 11-04-2006, 09:49 AM
  3. helpppp
    By The Brain in forum C Programming
    Replies: 1
    Last Post: 07-27-2005, 07:05 PM
  4. goto label not recomended?
    By electrolove in forum C Programming
    Replies: 10
    Last Post: 02-08-2003, 02:49 PM
  5. Need some help with a basic tic tac toe game
    By darkshadow in forum C Programming
    Replies: 1
    Last Post: 05-12-2002, 04:21 PM