注册 登录
编程论坛 C++教室

有没有人知道C++的清屏语句

noviceby 发布于 2006-12-19 21:32, 5966 次点击
有时候想显示内容之前把屏幕清干净,但不知道怎样做,有没有谁知道啊?
6 回复
#2
爱上夜2006-12-19 22:27
#include"conio.h"

clrscr(); 这样在C++中应该能用的啊!
#3
noviceby2006-12-20 00:01
用system("cls")也行
#4
tancui2006-12-20 10:33

自己说自己答,牛

#5
noviceby2006-12-20 11:16

提问时不会做嘛,后来会做了就不能说话??????

#6
yuyunliuhen2006-12-20 13:31

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;
}

[此贴子已经被作者于2006-12-20 13:35:46编辑过]

#7
noviceby2006-12-20 21:56
谢谢6楼的,学习了
1