如何清除控制台 [英] How can I clear console
问题描述
如标题。如何清除C ++中的控制台?
对于纯C ++ b
你不能。 C ++甚至没有控制台的概念。
程序可以打印到打印机,直接输出到文件,或者重定向到另一个输入程序为它所有关心。即使你可以在C ++中清除控制台,也会使这些情况显得更麻烦。
请参阅comp.lang.c ++中的此条目:FAQ:
操作系统特定
如果在程序中清除控制台仍然有意义,并且对操作系统特定解决方案感兴趣,
对于Windows(在您的标记中),请查看以下链接:
这些解决方案中最简单的是:
#include< stdlib.h>
int main(int argc,char * argv [])
{
system(cls);
return 0;
}
ncurses是一个支持控制台操作的库: As in the title. How can I clear console in C++? For pure C++ You can't. C++ doesn't even have the concept of a console. The program could be printing to a printer, outputting straight to a file, or being redirected to the input of another program for all it cares. Even if you could clear the console in C++, it would make those cases significantly messier. See this entry in the comp.lang.c++ FAQ: OS-Specific If it still makes sense to clear the console in your program, and you are interested in operating system specific solutions, those do exist. For Windows (as in your tag), check out these links: The simplest of these solutions is: Libraries (somewhat portable) ncurses is a library that supports console manipulation: 这篇关于如何清除控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
#include <stdlib.h>
int main(int argc, char* argv[])
{
system("cls");
return 0;
}