How can I set the cursor at the desired location on the console in C or C++?
I remember a function called gotoxy(x,y), but I think its deprecated. Is th
You can use this to set the cursor to specific coordinates on the screen, and then simply use cout<< or printf statement to print anything on the console:
#include
#include
using namespace std;
void set_cursor(int,int);
int main()
{
int x=0 , y=0;
set_cursor(x,y);
cout<<"Mohammad Usman Sajid";
return 0;
}
void set_cursor(int x = 0 , int y = 0)
{
HANDLE handle;
COORD coordinates;
handle = GetStdHandle(STD_OUTPUT_HANDLE);
coordinates.X = x;
coordinates.Y = y;
SetConsoleCursorPosition ( handle , coordinates );
}