Why doesn't
gotoxy(x, y);
work on dev c++?
What other way can i do this?
Printable View
Why doesn't
gotoxy(x, y);
work on dev c++?
What other way can i do this?
(because dev is crap [imho]) :)
try including conio.h
though it isnt included in all versions of conio.h
Ok, i allways hate to admit, but im wrong, dev sux, i'll just use mvc++
LOL
I shoulda stayed with mvc++
gotoxy() is not supported in all compilers because it is not part of the standard. You could always read the FAQ and then you wouldn't have asked this question in the first place.
hmm... here is a bit of code i like to simplify this...
with visual c++ this seems to work just fine.
Take a look at the text_loc(x, y) in specific. it should function like goto(x,y)
Code:#ifndef _CONSOLE_LIBRARY_INTERFACE
#define _CONSOLE_LIBRARY_INTERFACE
#include <windows.h>
WORD cl_fc_param = 0;
WORD cl_bc_param = 0;
void text_color(bool red, bool green, bool blue, bool bright)
{
cl_fc_param = 0;
if ( red ) cl_fc_param |= FOREGROUND_RED;
if ( green ) cl_fc_param |= FOREGROUND_GREEN;
if ( blue ) cl_fc_param |= FOREGROUND_BLUE;
if ( bright ) cl_fc_param |= FOREGROUND_INTENSITY;
SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), cl_fc_param|cl_bc_param );
}
void text_background(bool red, bool green, bool blue, bool bright)
{
cl_bc_param = 0;
if ( red ) cl_bc_param |= BACKGROUND_RED;
if ( green ) cl_bc_param |= BACKGROUND_GREEN;
if ( blue ) cl_bc_param |= BACKGROUND_BLUE;
if ( bright ) cl_bc_param |= BACKGROUND_INTENSITY;
SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), cl_fc_param|cl_bc_param );
}
void text_loc(int x, int y)
{
COORD cursor_coordinates;
cursor_coordinates.X = x;
cursor_coordinates.Y = y;
SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), cursor_coordinates );
}
void console_title(const char* title)
{
SetConsoleTitle(title);
}
#endif