Thread: i want a line

  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    142

    i want a line

    in the old days you would use (goto 67) to get to a spacific line as some of you would know. if you can, how do you do this in c++

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    c and c++ do not have native line drawing because that is an os-specific task. For MS-Windows os you have to use MS-Windows win32 api GUI drawing functions. I don't think there is a way to draw lines in a 32-bit console program. Of course you can use the old ancient Turbo C++ MS-DOS compiler, but it's not very good for learning the c++ language.

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    I think he meant loops. Like if you have code on line 2 type goto 2. However in C++ you can do this but you need to put this on that line:
    Code:
    main:  //starting point
    //...code whatever
    goto main;  //this code takes you back to the main: spot.
    Look up loops, I'm sure there's a tutorial on them on this website.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    jmd15,
    yup, this will do what was asked.
    but raises the question ( for me ):
    is the goto method something to be encouraged or discouraged?
    since goto loops can easily create infitely repeating loops, aka app lockups.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  5. #5
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    >>>is the goto method something to be encouraged or discouraged

    Highly discouraged. goto has its uses but they are few and far between and never should a goto be used to replace a loop construct.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    125
    infinitely repeating loops can be made using any form of loop. The real problem is that goto commands can make your program very messy.
    It's better to stick with the other methods of program control C++ provides.
    Typing stuff in Code::Blocks 8.02, compiling stuff with MinGW 3.4.5.

  7. #7
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    That's what I thought. figured getting it confirmed in a question where someone wants to use it would benefit original questioner.

    and a goto loop can cause you to jump around the app to much, breaking function containers etc.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to do encryption in C
    By sankarv in forum C Programming
    Replies: 33
    Last Post: 12-28-2010, 11:01 AM
  2. Reading a file line by line
    By Raskalnikov in forum C Programming
    Replies: 8
    Last Post: 03-18-2009, 11:44 PM
  3. Pointer and Polymorphism help.
    By Skyy in forum C++ Programming
    Replies: 29
    Last Post: 12-18-2008, 09:17 PM
  4. Printing Length of Input and the Limited Input
    By dnguyen1022 in forum C Programming
    Replies: 33
    Last Post: 11-29-2008, 04:13 PM
  5. Finding carriage returns (\c) in a line
    By JizJizJiz in forum C++ Programming
    Replies: 37
    Last Post: 07-19-2006, 05:44 PM