gotxy, the FAQ confused me

This is a discussion on gotxy, the FAQ confused me within the C++ Programming forums, part of the General Programming Boards category; When I looked to see how to use gotoxy in the Programming FAQ it just confused me instead of helping ...

  1. #1
    His posts are far and few Esparno's Avatar
    Join Date
    Mar 2002
    Posts
    100

    gotxy, the FAQ confused me

    When I looked to see how to use gotoxy in the Programming FAQ it just confused me instead of helping me. My question is how would I use gotoxy in a console window, what I mean is, how would I print, lets just say "Hello world", to the coordinates 50, 50 in the console window?
    Signature is optional, I didnt opt for one.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Just copy and paste Sunlight's code, and say

    gotoxy(50,50)

  3. #3
    His posts are far and few Esparno's Avatar
    Join Date
    Mar 2002
    Posts
    100
    But when i try to make the code work i get a lot of error messages, heres my code:

    PHP Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <windows.h>
    void main(void)
    {
    void gotoxy(int xint y)
    {
       
    COORD coord;
       
    coord.x;
       
    coord.y;
       
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }
    gotoxy(50,50);
    printf("hello");

    Signature is optional, I didnt opt for one.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <windows.h>
    
    void gotoxy(int x, int y);
    
    int main(void)
    {
       gotoxy(50,50);
       printf("hello");
       return 0;
    }
    
    void gotoxy(int x, int y)
    {
       COORD coord;
       coord.X = x;
       coord.Y = y;
       SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    }
    Last edited by swoopy; 03-22-2002 at 02:59 PM.

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    Code:
    #include <iostream.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <windows.h>
    void main(void)
    {
      void gotoxy(int x, int y)
      {
         COORD coord;
         coord.X = x;
         coord.Y = y;
         SetConsoleCursorPosition(
            GetStdHandl(STD_OUTPUT_HANDLE), coord);
      }
      gotoxy(50,50);
      printf("hello");
    }
    This won't work because C++ doesn't support nested functions. All functions have to be at the top lexical level or bad things happen. And don't use void main, it's evil.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 01:17 PM
  2. Redirect FAQ...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 05-21-2007, 04:48 PM
  3. FAQ Check/Lock
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-15-2002, 11:21 AM

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