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