А АWednesday 6 December 2017

Using Gotoxy in Dev C++.

Hi all.

My son deals with IDE Dev C++. Why does he use this IDE? This is powered by his college policy in IT-class.

And yesterday he came to me with function Gotoxy(). It's absolutely not working. Hmm. I think this IDE doesn't support all features from Borland C++.

So, 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++ we have to add #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);
 }

Good luck.

No comments:

Post a Comment

А что вы думаете по этому поводу?

Версия на печать

Популярное