How to clear the console screen without connecting libraries ???
Answer 1, authority 100%
# include & lt; stdlib.h & gt;
int main (int argc, char * argv [])
{
system ("cls");
return 0;
}
For win:
void clear () {
COORD topLeft = {0, 0};
HANDLE console = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO screen;
DWORD written;
GetConsoleScreenBufferInfo (console, & amp; screen);
FillConsoleOutputCharacterA (
console, '', screen.dwSize.X * screen.dwSize.Y, topLeft, & amp; written
);
FillConsoleOutputAttribute (
console, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE,
screen.dwSize.X * screen.dwSize.Y, topLeft, & amp; written
);
SetConsoleCursorPosition (console, topLeft);
}
For * nix:
void clear () {
std :: cout & lt; & lt; "\ x1B [2J \ x1B [H";
}
See here for other known options for clearing the console screen.
asm option for the gifted:
PUSHA;
XOR EAX, EAX;
XOR EBX, EBX;
XOR ECX, ECX;
XOR EDX, EDX;
MOV AH, 6;
MOV DX, 174fh;
INT 10h;
POPA;
This option will not work in Protected Mode.
Answer 2, authority 75%
Like this
cout & lt; & lt; "\ 033 [2J \ 033 [1; 1H";
There are two commands here – clear the screen \ 033 [2J
And move the cursor to the upper left corner \ 033 [1; 1H