首先要说明的是,这里的清屏指的是在terminal(Linux下)或Dos-command(Windows下)的清屏。
1.For instance, with Borland, you might do this: (在Borland环境下)
#include <conio.h> // ...
clrscr();
2.For some versions of Microsoft, you might do this: (Microsoft环境下,应该就是Windows环境中)
#include <conio.h> // ...
_clearscreen(_GCLEARSCREEN);
#include <stdlib.h>
system("cls"); // For Dos/Windows et al "console app" (cls就是命令行中的清屏指令)
system("clear"); // For some UNIX's, LINUX, etc. (Mac OS X中这个命令可以使用, clear也为清屏命令)
system("tput clear"); // For some UNIX's (没有测试)
文章其他的地方,就是在C++的环境下来完成清屏,这里就不在说了。
如果有不懂,可以留言。自己还是比较倾向用3,一是可能Mac OS X只能用这个来实现,
二可能是因为system()这个函数的强大,里面基本上可以使用系统指令,如:system("mkdir test");
(在当前目录下建立test文件夹)或者 system("...") (很多了~)
本文介绍了不同编程环境下清除终端屏幕的方法,包括Borland、Microsoft及多种UNIX系统下的具体实现方式。
3878





