gotoxy()
is a standard C function defined in <conio.h>, but it will not work in ANSI C compilers such as Dev-C++. 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);
}
//sample code
#include<stdio.h>
#include<conio.h>
#include <windows.h>
//Defines gotoxy() for ANSI C compilers.
void gotoxy(short x, short y) {
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
main()
{
int x, y;
x = 10;
y = 10;
gotoxy(x, y);
printf("Welcome to C program.");
getch();
return 0;
}
by: boybalda46