使用 C++ 代码在 Linux 中清除终端 [英] Clearing terminal in Linux with C++ code
本文介绍了使用 C++ 代码在 Linux 中清除终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,我一直在研究如何做到这一点,但假设我正在运行一个在终端上有大量输出的程序,我将如何从我的程序中清除屏幕以便我可以保留我的程序跑步?
Okay, I have been researching on how to do this, but say I am running a program that has a whole bit of output on the terminal, how would I clear the screen from within my program so that I can keep my program running?
我知道我可以在终端中输入 clear
并且它可以很好地清除它,但就像我说的那样,对于这个程序,它对我更有益.
I know I can just type clear
in terminal and it clears it fine, but like I said, for this program it would be more beneficial for me.
我发现了一些有用的东西,但是,我不确定它是什么或它在做什么.
I found something that works, however, I'm not sure what it is or what it is doing.
cout << " 33[2J 33[1;1H";
这可行,但我不知道它是什么,如果您能解释一下,我将不胜感激.
That works but I have no clue what it is, if you could explain it, than I would much appreciate it.
推荐答案
这些是 ANSI 转义码.第一个 (