如何上去的控制台程序(C ++)一行 [英] How to go up a line in Console Programs (C++)
问题描述
在C ++我想回去了行添加一些字符。
这里是我的code迄今:
In C++ I'm trying to go back up a line to add some characters. Here is my code so far:
cout << "\n\n\n\n\n\n\n\n\n\n\xc9\xbb\n\xc8\xbc"<<flush;
Sleep(50);
正如你所看到的,我有10个换行符。在我的动画,一个新块将从屏幕的顶部落下。但我不知道怎么回去了这些行添加我需要的字符。我试过\\ R,但是这么想的做任何事情,\\ B就这么想的要么去了previous线。此外,究竟冲洗做什么呢?我只在C ++编程2天左右,所以我对于新手= P
As you can see, I have 10 newline characters. In my animation, a new block will be falling from the top of the screen. But I don't know how to go back up those lines to add the characters I need. I tried \r, but that dosen't do anything and \b dosen't go up the previous line either. Also, what exactly does flush do? I've only been programming in C++ for about 2 days so I'm a newb =P.
太感谢了!
基督教
推荐答案
如果您的控制台支持 VT100转义序列一>(大多数人),那么你可以使用 ESC [A
,就像这样:
If your console supports VT100 escape sequences (most do), then you can use ESC [ A
, like this:
cout << "\x1b[A";
移动光标一行。视需要重复。
to move the cursor up one line. Repeat as necessary.
这篇关于如何上去的控制台程序(C ++)一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!