Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道你不应该使用 system("clear") 但我的教授坚持使用它。由于某种原因,它不起作用。我在 linux 系统上并使用 ubuntu 13.04 64bit 中的默认终端。我已经尝试了 cout 版本和系统清除,但不包括 cstdlib。还是没有成功TT
system("clear");
cout << "\033[2J\033[1;1H";
EDIT1:使用 g++ 编译器。它也在“驱动程序”程序中运行。因此,一个 cpp 文件尝试清除屏幕,另一个打印代码。我不认为这有什么不同。
我已经测试了这段代码:
#include <cstdlib> int main() { system( "clear" ); return 0; }
这个代码:
#include <stdlib.h> int main() { system( "clear" ); return 0; }
使用: g++ main.cpp -o system
g++ main.cpp -o system
两者都为我工作。你能详细说明问题吗?