Thread: goto

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    9

    Question goto

    ok, say I am using the goto command, how do I use it effectively.

    Every time I try it tells me I have an error or two.

    If anyone can help me I would greatly appreciate it,
    thx.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    9

    Question la la

    hello

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    The most effective way to use it is not to =]

    Seriously, goto, at its best, is only AS simple as loop/condition structures (do..while, while, for, if, switch) and is never simpler. It is never the best method for solving a problem and is almost always a problem.

    Even using gotos which are exactly equivalent to a loop structure is not recommended because of scope. Variables declared in a loop have scope only within the loop -- not so with gotos. Further, the use of gotos negates some of the compiler's ability to generate warnings.

    If you want to learn C++, you should pretend goto does not exist. Goto-style code, aka "spaghetti code", is hideously bad style. It is harder to read, harder to debug, and harder to write.

    Goto is something you use only in languages where there IS nothing else. In C/C++, you don't need to learn how to use it -- you learn how NOT to use it!

  5. #5
    Registered User EvenFlow's Avatar
    Join Date
    Oct 2001
    Posts
    422
    There is nothing that you can do with goto that you can't do with a for loop or while loop. Seriously, there is no need whatsoever to use goto. It is really bad practice and it is very inefficient.
    Ramble on...

  6. #6
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    true, but goto's can accomplish some things more effeciently on rare occasions...
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  7. #7
    Registered User EvenFlow's Avatar
    Join Date
    Oct 2001
    Posts
    422
    >>true, but goto's can accomplish some things more effeciently on rare occasions...<<

    Perhaps, but not really enough to warrant its use when other options are available.
    Ramble on...

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. goto command
    By jhwebster1 in forum C Programming
    Replies: 3
    Last Post: 02-21-2006, 12:32 PM
  3. Does goto have a glitch or...?
    By Blackroot in forum C++ Programming
    Replies: 9
    Last Post: 02-18-2006, 10:40 AM
  4. helpppp
    By The Brain in forum C Programming
    Replies: 1
    Last Post: 07-27-2005, 07:05 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