Originariamente inviato da MItaly
Su che piattaforma sei?
Domanda lecita e che approvo.
Ovviamente in campo unix la sintassi si avvale di clear, in ambiente Windows le possibilità sono varie:
codice:
#include <stdlib.h>
system("cls");
oppure
codice:
#include <conio.h>
scrclr();
oppure altro metodo più efficace (secondo MSDN)
codice:
void ClearScreen()
{
COORD coordScreen = {0, 0}; DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return;
}
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
if(!FillConsoleOutputCharacter(GetStdHandle(STD_OUTPUT_HANDLE), (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten))
{
return;
}
if(!GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi))
{
return;
}
if(!FillConsoleOutputAttribute(GetStdHandle(STD_OUTPUT_HANDLE), csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
{
return;
}
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coordScreen);
}