h1

Using gotoxy() in Dev-C++

January 30, 2011

gotoxy() is a standard C function defined in <conio.h>, but it will not work in ANSI C compilers such as Dev-C++. Why? Because gotoxy() is a Turbo-C++ specific function, which means it is not part of the standard. However, if you insist on using console functions, you can define your own function by using member functions available in <windows.h>

To use gotoxy() in Dev-C++, #include <windows.h> and insert this snippet before the main() function:


//Defines gotoxy() for ANSI C compilers.
void gotoxy(short x, short y) {
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

30 comments

  1. Thanks for the help!


  2. what is mean by { gotoxy(y–,5) }?


  3. guys can anyone around here give me the alternative source code for devcpp. the code provided here does not work 😦


  4. It really working but can tell what does
    {
    COORD pos = {x, y};
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
    }
    means???????



Comments are closed.

%d bloggers like this: