Now anywhere in your code you can simply type something like "gotoxy(3,5)" and the cursor will move to that point.
Hope that helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-10-30
You could also #include <conio.c> which is a work-a-round file written by Hongli Lai, tkorrovi, and Andrew Westcott. It is public domain and was included in Dev-Cpp 4.9.6.0, or maybe earlier.
Try this console app...
#include <conio.c>
int main(void)
{
gotoxy(10, 12);
printf("This should be at 10,12\n");
system("PAUSE");
return 0;
}
In this case, you can get away with just including <conio.c> because conio.c itself includes conio.h, stdio.h, stdlib.h, and windows.h. The non-debug executable is 5k.
To make a smaller executable, try this...
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
//Note that conio.c is *NOT* included.
int main(void)
{
//This is the actual gotoxy function from conio.c.
void gotoxy(int x, int y)
{
COORD c;
c.X = x - 1;
c.Y = y - 1;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
gotoxy(10, 12);
printf("This should be at 10,12\n");
system("PAUSE");
return 0;
}
This console executable is 3k... you save 2k. (It would still be a bargin at twice the price. hehe.) Hope this helps.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
can some one help me get the GOTOXY goign in dev c++?
Because Mingw doesn't include functions like that in its conio.h (they're really DOS functions and we're creating 32-bit Windows binaries here).
You'll want to use the Win32 console API. I'm going to be nice and show you how it's done:
First, make sure to #include <windows.h>
Here's your gotoxy function:
void gotoxy(int X, int Y)
{
COORD coord;
coord.X = X;
coord.Y = Y;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsole, coord);
}
Now anywhere in your code you can simply type something like "gotoxy(3,5)" and the cursor will move to that point.
Hope that helps.
You could also #include <conio.c> which is a work-a-round file written by Hongli Lai, tkorrovi, and Andrew Westcott. It is public domain and was included in Dev-Cpp 4.9.6.0, or maybe earlier.
Try this console app...
#include <conio.c>
int main(void)
{
gotoxy(10, 12);
printf("This should be at 10,12\n");
system("PAUSE");
return 0;
}
In this case, you can get away with just including <conio.c> because conio.c itself includes conio.h, stdio.h, stdlib.h, and windows.h. The non-debug executable is 5k.
To make a smaller executable, try this...
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
//Note that conio.c is *NOT* included.
int main(void)
{
//This is the actual gotoxy function from conio.c.
void gotoxy(int x, int y)
{
COORD c;
c.X = x - 1;
c.Y = y - 1;
SetConsoleCursorPosition (GetStdHandle(STD_OUTPUT_HANDLE), c);
}
gotoxy(10, 12);
printf("This should be at 10,12\n");
system("PAUSE");
return 0;
}
This console executable is 3k... you save 2k. (It would still be a bargin at twice the price. hehe.) Hope this helps.