Goto/Label

This is a discussion on Goto/Label within the Game Programming forums, part of the General Programming Boards category; I was wondering if any one here knows how to use Goto, it would be a help of you could ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    9

    Goto/Label

    I was wondering if any one here knows how to use Goto, it would be a help of you could tell me.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,203
    Dont use goto, period. Use a loop for or whileloop instead.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    while i disagree with shakti, goto's should be avoided till you are a well seasoned programmer and know the in's and out's of the language and how and where to use a goto in the rare case you need one, i recommend finding another solution untill you know for sure when and where you need one... and if you dont already know how to use one you probably dont know...

    Code:
    int main(void)
    {
        goto GOTO_LABEL;
        // skipped code...
        GOTO_LABEL:
        // code...
        return 0;
    }
    on a side note this belongs in the C or C++ forum...
    Last edited by no-one; 05-20-2005 at 02:53 PM.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    9
    Thanks. I need this to make a Text based game. When I use basic, Goto is what I use most, it's all I know how to use for this. Such as, the inputer makes a desion, then the Goto sends them to the next desion and so on. I don't know if any other loops can do that.

  5. #5
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> I don't know if any other loops can do that.

    If statements and for/while loops most certainly can and are definately worth learning. GOTO should be more of a last resort.

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    9
    I see what your saying, I've just been thinkin too big...or small.

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by RedRookie
    I was wondering if any one here knows how to use Goto, it would be a help of you could tell me.
    Correct me if I'm wrong, but it has few uses:
    • Common exit/cleanup code from a function.
    • Breaking out of nested loops without extra stuff.
    • Breaking a loop from a switch (without extra stuff).
    [edit]It's as useful as a "Branch Always" to an assembly programmer, but used where the C languages don't quite provide it automatically.
    Last edited by Dave_Sinkula; 05-21-2005 at 09:40 PM.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    You guys and your goto.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21