声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3792|回复: 2

[C/C++] [讨论]请问c++清屏的语句是什么?(+1-3分)

[复制链接]
发表于 2006-6-16 20:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
请问c++清屏的语句是什么?
回复
分享到:

使用道具 举报

发表于 2006-6-22 12:46 | 显示全部楼层
在TC中可用clrscr进行清屏操作。<BR>在VC下可用system函数进行DOS的清屏,使用方式:<BR>system("cls");
发表于 2006-6-23 10:27 | 显示全部楼层
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, &amp;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 &lt;stdlib.h&gt;<BR>#include &lt;stdio.h&gt;<BR><BR>int main(int argc, char* argv[])<BR>{<BR>int i = 0;<BR><BR>for (i=0; i&lt;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>
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-12 17:54 , Processed in 0.209267 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表