Thread: problem in goto command

  1. #16
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    You should learn how it works, nothing really more. Are we really going to turn this into another debate about 'goto'? This has been done so many times before, and (most importantly), has never helped the OP.
    It's already a debate about goto.


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #17
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    It's already a debate about goto.
    Quzah.
    I understand that this is an ongoing debate; my question is mainly should we always start this debate everytime a newb asks about goto? It really seems counter-productive. "We" understand this debate however, in most cases, the newb will not and thus could derive false conclusions.This is, one of the many, reasons I have considered the possibility of starting a "members only" kind of programming site.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #18
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    I understand that this is an ongoing debate; my question is mainly should we always start this debate everytime a newb asks about goto?
    It's a knee jerk reaction. Instead of just answering his question, everyone has to point out why he should never ever use goto and shouldn't even learn about it. I'm not saying it's right or wrong, it's just what everyone does.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #19
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    It's a knee jerk reaction. Instead of just answering his question, everyone has to point out why he should never ever use goto and shouldn't even learn about it. I'm not saying it's right or wrong, it's just what everyone does.
    Quzah.
    I would tend to agree with your concept, however I believe base on the OP's code and questions, the conservative route in this case was appropriate.

    Now, are there reasons to use goto in C? My answer would be yes. Even more so, sometimes the reason to use it may seem convoluted and not immediately apparent (John Carmack), however this was not the case. Personally, I would prefer the concept buried in the language until at least 3rd or 4th year level; past once you understand what exactly the effect of your code is on the computer.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    Now, are there reasons to use goto in C? My answer would be yes.
    I wish I could make labels be nubmers.
    Code:
    10: printf( "hello world\n" );
    20: goto 10;
    That way I could pretend I was programming in BASIC.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Haha...we all wish we could go back to those days......
    Quote Originally Posted by quzah
    Code:
                                     _.-_
                                 __.'  o "-.
                        ___----""       ,,,'
                   __--"             _-_ ^^;
           ____--""  ___         _-\"   `""
    ..--===-------"""   "(   __-"  ,}
                        .'_/"\
                      .'/"  `\`._
                      "-_c    "
    Unfortunately..................................... ................
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  7. #22
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by AndrewHunter View Post
    Unfortunately..................................... ................
    Unfortunately, someone knocked the top of your dino's head off.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #23
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by quzah View Post
    Unfortunately, someone knocked the top of your dino's head off.
    Quzah.
    LOL.....who wanted that code highlighting anyway.

    EDIT: Ok that was suppose to be the "roll eyes" smiley but I received the "window licker on the special bus smiley". I would like to lodge a complaint......
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  9. #24
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by quzah
    I wish I could make labels be nubmers.
    You could approximate that, e.g.,
    Code:
    M10: printf( "hello world\n" );
    M20: goto M10;
    then claim that this is M BASIC
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #25
    Registered User
    Join Date
    Oct 2011
    Location
    india
    Posts
    18
    the order is as follows:

    Code:
    int number;
    printf ("www.");
    
    goto x;
    
    z:
    
    printf ("you");
    
    goto y;
    
    x:
    printf ("ilove");
    
    goto z;
    y:
    
    printf (".com");
    
    getch ();
    
    return 0;
    
    }

  11. #26
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    vikasvijayan, don't you ever read the previous responses to the threads that you reply to?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #27
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    All he did is take the code box from the first post and hit enter after every line.


    Quzah.
    Hope is the first step on the road to disappointment.

  13. #28
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by AndrewHunter View Post
    I understand that this is an ongoing debate; my question is mainly should we always start this debate everytime a newb asks about goto? It really seems counter-productive. "We" understand this debate however, in most cases, the newb will not and thus could derive false conclusions.This is, one of the many, reasons I have considered the possibility of starting a "members only" kind of programming site.
    Sounds like an FAQ in the making...

  14. #29
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Quote Originally Posted by quzah View Post
    I would down mod this if I could.

    You should know about goto. You should know when to use it, and how it works. Not knowing about it isn't going to help you when you run into it.

    Quzah.
    Let me rephrase: The less you know about goto in the early stages of learning a programming language, the better.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  15. #30
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    The guys who wrote "Numerical recipes" make an interesting point regarding goto. They say it's not the goto itself that is the problem, but the label it branches to. When you see a label you immediately think "Uh oh! Now I have to find what bit of code transfers control here". I'm not sure I agree, particularly if the label is well-named and you never use goto to jump backwards, but I get their point.
    Code:
    while(!asleep) {
       sheep++;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Chmod command problem
    By JFonseka in forum C Programming
    Replies: 22
    Last Post: 10-22-2007, 07:09 AM
  2. Problem with goto
    By Tropicalia in forum C++ Programming
    Replies: 36
    Last Post: 09-30-2006, 07:33 PM
  3. goto command
    By jhwebster1 in forum C Programming
    Replies: 3
    Last Post: 02-21-2006, 12:32 PM
  4. Goto Command
    By swgh in forum C++ Programming
    Replies: 13
    Last Post: 04-30-2005, 05:24 PM
  5. problem with switch command
    By DoItAllMom115 in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2003, 04:33 PM