有很多方法可以做到这一点,根据您想要投入多少精力,您可以在终端窗口中使用ascii文本做很多很酷的事情.
高级:ncurses库
最简单:正如其他人所说,只需使用\r没有换行的回车.
编辑:使用ESC序列返回两个字符的示例:
#include <iostream>
#define ESC char(0x1B)
int main(){
std::cout << "This will overwrite 'rs' in the following: characters" << ESC << "[2D" << "xx" << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)