I want to emulate backspace in programming and implemented as 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 I get a result like this
How can I get a result just like below without the need of replacing the tails with blank space
123
That is to say how can I delete, rather than replace, those character after the cursor which has been backspaced.