Using X,Y Coords in DOS Console

This is a discussion on Using X,Y Coords in DOS Console within the C++ Programming forums, part of the General Programming Boards category; Hi, I need to move a word arround the screen using the x,y coordinants in the DOS Console. Like for ...

  1. #1
    Registered User BigSter's Avatar
    Join Date
    Nov 2001
    Posts
    47

    Using X,Y Coords in DOS Console

    Hi,
    I need to move a word arround the screen using the x,y coordinants in the DOS Console. Like for example I wanted to move the word "Hi!" arround the screen using input from the user.

    x=1;
    y=2;
    "Hi!" location = (x,y);

    Thanks

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    The function to place the cursor at a specific location is called 'gotoxy( x,y )' for other compilers. For MS VC you have to look in the FAQ to know how to write your own gotoxy.

    When you are at the location, just use your favorite output method. printf, cout etc.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User BigSter's Avatar
    Join Date
    Nov 2001
    Posts
    47
    So like if I wanted to print the word "Hi!" using cout, with x=5 and y=5. Could you give me a simple example.
    Thanks

    cout<<"Hi!"<<endl;

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    PHP Code:
    #include <iostream>

    using namespace std;

    // Prototype for your own gotoxy function here

    int main()
    {
        
    gotoxy5);
        
    cout << "Hi";
        return 
    0;
    }

    // Implementation of your own gotoxy function here 
    Please consult the FAQ on how to write the gotoxy function in MSVC.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User BigSter's Avatar
    Join Date
    Nov 2001
    Posts
    47
    Thanks

  6. #6
    Registered User Kuplex's Avatar
    Join Date
    Dec 2001
    Posts
    18

    Wink Try this for MS VC++

    #include <windows.h>
    #include <conio.h>

    void gotoxy(int x, int y)
    {
    static HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord = {x, y};
    SetConsoleCursorPosition(hConsole, coord);
    }
    Kuplex
    "The only thing you can count on is uncertainty."

    Must I explain myself futher?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Internet Programming for DOS Console
    By KoolFriend in forum C++ Programming
    Replies: 9
    Last Post: 09-27-2004, 11:49 AM
  2. dos to win32 console
    By lambs4 in forum C Programming
    Replies: 3
    Last Post: 04-05-2003, 11:04 AM
  3. windows dos console
    By dune911 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-16-2002, 11:30 PM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM

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