if it is not present then what is the way to make our own.
Back a while I ported some old project and there was no gotoxy
and some others so I made quick and dirty ones with Windows.
Note that I used get_key() to replace getch() which doesn't
seem to work in Windows console. This source is highly
non-portable
#include <windows.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <conio.h>
#include <sys\stat.h>
HANDLE wHnd; //Handle to write to the console
HANDLE rHnd; //Handle to read from the console
void get_window_handles()
{
//Set up the handles for reading/writing, call
//this once before using routines
wHnd=GetStdHandle(STD_OUTPUT_HANDLE);
rHnd=GetStdHandle(STD_INPUT_HANDLE);
}
void clrscr() { system("CLS"); }
void gotoxy(short x, short y)
{
COORD c;
c.X=x; c.Y=y;
SetConsoleCursorPosition(wHnd,c);
}
void textattr(unsigned char c)
{
int textColor=c & 0x0f;
int backGroundColor=(c & 0xf0)>>4;
SetConsoleTextAttribute(wHnd,
(WORD)((backGroundColor << 4) | textColor));
}
short get_key()
{
INPUT_RECORD rec;
DWORD num;
do { ReadConsoleInput(rHnd, &rec, 1, &num); }
while (num==0 || rec.EventType!=KEY_EVENT ||
rec.Event.KeyEvent.bKeyDown==FALSE);
short rv=rec.Event.KeyEvent.uChar.AsciiChar;
//if no ascii code detected, return virtual key code (VK_*)
if (rv==0) rv=rec.Event.KeyEvent.wVirtualKeyCode;
return rv;
}