Goto for a purpose... Is it legaL?

This is a discussion on Goto for a purpose... Is it legaL? within the C++ Programming forums, part of the General Programming Boards category; I have created a function for my text game that places the text on different places on the screen by ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479

    Goto for a purpose... Is it legaL?

    I have created a function for my text game that places the text
    on different places on the screen by using the X Y syntax.

    Here is the function:

    Code:
    void gotoxy( int x, int y ) 
    { 
        COORD c; 
    
    	c.X = x - 1 ; 
     	c.Y = y - 1 ; 
     	
     	// TO REMEMBER: 1ST NUMBER SPACES IN :: 2ND NUMBER SPACES DOWN
    
    	SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), c ) ; 
    }
    Is this still frowned appon, as I am finding it to be very useful when working with colour strings.

    Any comments taken onboard!! Thanx

  2. #2
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398
    I think you're getting this mixed-up with the C++ goto command. The goto command allows you to jump to a particular place in your program. It is considered bad practice to jump-around like that.

    There's nothing wrong with using gotoxy(). But, you should be aware that it's non-standard, so it can't be used on all machines, and your code may not be portable.
    Last edited by DougDbug; 01-16-2006 at 05:37 PM.

  3. #3
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,479
    oh ok thanks dougdbug. Thats cleared that up for me!

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, 08:26 PM
  2. helpppp
    By The Brain in forum C Programming
    Replies: 1
    Last Post: 07-27-2005, 08:05 PM
  3. Resource ICONs
    By gbaker in forum Windows Programming
    Replies: 4
    Last Post: 12-15-2003, 07:18 AM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 02:27 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, 05:21 PM

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