|
1:system("CLS");//windows或DOS下。
system("clear");//linux下
2:另外,VC中可以做个函数如:
void ClearScreen(void)
{
CONSOLE_SCREEN_BUFFER_INFO bInfo;
GetConsoleScreenBufferInfo( hOut, &bInfo );
COORD home = {0, 0};
WORD att = bInfo.wAttributes;
unsigned long size = bInfo.dwSize.X * bInfo.dwSize.Y;
FillConsoleOutputAttribute(hOut, att, size, home, NULL);
FillConsoleOutputCharacter(hOut, ' ', size, home, NULL);
}
3:clrscr()函数它在conio.h头文件中
4:例子:
system("cls") 的测试。
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int i = 0;
for (i=0; i<20; i++)
printf("print number i = %d \n",i);
getchar();
int iClsReturn;
iClsReturn = system("cls");
if (iClsReturn == 0)
{
printf("cls screen success!");
}
else
{
printf("cls screen failure!");
}
getchar();
return 0;
} |
|