Wednesday, October 14, 2020

CLEAR SCREEN IN c++

#include <sys/ioctl.h>
#include <unistd.h>
  

For gotoxy():-

void gotoxy(int x,int y)
{
    printf("%c[%d;%df",0x1B,y,x);

}

 void clrscr()
{
        gotoxy(0,0);

        struct winsize w;
        ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);

        for (int x = 0; x < w.ws_row; x++)
        {
            for(int y = 0; y < w.ws_col; y++)
            {
                cout << " ";
            }
        }
        gotoxy(0, 0);



No comments:

Post a Comment