Thread: gotoxy

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    45

    gotoxy

    A simple question: in the FAQ is a gotoxy function;
    how do I use it?

    This doesnt work:
    Code:
    gotoxy(100,20);
    cout<<"Being on loacation 100,20";

  2. #2
    Registered User quagsire's Avatar
    Join Date
    Jun 2002
    Posts
    60
    The screen is usually only 80x25 characters in size. When you call it with 100 as x parameter it will ignore the call as this is bigger than 80. Try using values that fall within the screen size
    Code:
    gotoxy(10,15);
    cout << "row 15, column 10";

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    And how do I go back to de default?

    Code:
    gotoxy(20,10);   //only 8ox25
    cout<<"hi";
    
    gotoxy(0,0);
    cout<<" how are you?";
    does not work because the program wil output 'hi' and 'how are you'
    all in the first line

  4. #4
    Are you using gotoxy() from cronio.h? Or are you using a different one?

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Are you using gotoxy() from cronio.h? Or are you using a different one?
    Might be this one
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  6. #6
    I know, thats why I asked. But he could have copied it wrong.

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    The one from the faq, it does work but not if I want to use it a second time beacause then he will use only the second and skips the first

  8. #8
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Try flushing the buffer before you call the second gotoxy().

    Use this maybe:

    cout <<"hi " <<endl;
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  9. #9
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    Hey you're right

    Code:
    gotoxy(20,20);
    cout<<"Hi"<<endl;
        
    int ch;
    while ((ch = cin.get()) != '\n' && ch != EOF); 
    
    gotoxy(10,11);
    cout<<"Hi"<<endl;
    This doe work, only one thing; the bufferflush part waits for an enter so the output is now:
    : 'hi' (on coordinate 20,20)
    : press enter
    :'hi (on coordinate 10,11)

    the enter part annoys me a bit, any suggestions?

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>the enter part annoys me a bit, any suggestions?
    Yes, the code you've added flushed the input buffer, I meant for you to flush the output buffer Just using <<endl should have fixed your problem.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    Registered User
    Join Date
    Jan 2003
    Posts
    45
    oh.. well, thank you anyway

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What is gotoxy??
    By Beachblue in forum C Programming
    Replies: 6
    Last Post: 11-23-2008, 01:24 AM
  2. Tic Tac Toe movement
    By $l4xklynx in forum Game Programming
    Replies: 4
    Last Post: 11-06-2008, 07:22 PM
  3. gotoxy(); help!!
    By clique in forum C Programming
    Replies: 2
    Last Post: 10-07-2008, 04:08 AM
  4. Want to see if I am using gotoxy the right way ...
    By o0obruceleeo0o in forum C++ Programming
    Replies: 5
    Last Post: 04-22-2003, 04:17 PM
  5. Is gotoxy ansi?
    By MeneLaus in forum C Programming
    Replies: 2
    Last Post: 05-18-2002, 02:48 PM