c++ - How can I delete characters in stdout by programming? -


i want emulate backspace in programming , implemented below.

// del.cpp #include <iostream> using namespace std;  int main() {     cout << "123456";     cout << "\b\b\b" /* backspace key */<< '\x7f' /* del key */ << '\x7f' << '\x7f';     cout << endl;     return 0; } 

but result enter image description here

how can result below without need of replacing tails blank space

123 

that how can delete, rather replace, character after cursor has been backspaced.

use "clear end of line" escape sequence, csi k.

cout << "123456"; cout << "\b\b\b\033[k"; cout << endl; 

for list of escape sequences, see ansi escape code (wikipedia). of course, not of them work on terminals, these days, software terminals, wouldn't worry it.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -