Results 1 to 9 of 9

Thread: gotoxy() without changing y

  1. #1

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185

    gotoxy() without changing y

    how can I move the X position with gotoxy() without changing the Y position?
    To understand recursion, one must first understand the concept of recursion.

  2. #2
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    X position of?

  3. #3

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    the X position where cout prints stuff..
    To understand recursion, one must first understand the concept of recursion.

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I wrote this code last semester at school because I didn't dig how setw() managed things:

    Code:
    #include <windows.h>
    
    //function to move the cursor x spaces horizontally:
    void SetXPos(int x) {
    
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
        COORD coord;
    
        GetConsoleScreenBufferInfo(hConsole, &csbiInfo);
    
        coord.X = x;
        coord.Y = csbiInfo.dwCursorPosition.Y;
    	
        SetConsoleCursorPosition(hConsole, coord);
    }
    Hope this helps.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    gotoxy is Borland-specific. I hope you know that.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    But it can be recreated easily:

    Code:
    void gotoxy(int x, int y) {
    
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD coord;
    
        coord.X = x;
        coord.Y = y;
    	
        SetConsoleCursorPosition(hConsole, coord);
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7

    Thread Starter
    Addicted Member DarkMoose's Avatar
    Join Date
    Jul 2000
    Location
    in a box
    Posts
    185
    hmm, so is conio.h borland specific or something?
    To understand recursion, one must first understand the concept of recursion.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    No, not really. Nearly every compiler has conio.h. But the contents are not standardized and vary greatly from compiler to compiler.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The "standard" way of doing this is with ncurses, but I don't know if there's a Windows port of it. Take a look
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width