Console writing, delete characters
My question concerns deleting already written chars in the console. Is there a way to do it? Lets say i write 10 spaces to开发者_如何转开发 the console. Can i delete some to make space for other chars without the output exeeding 10 chars? I use a special libary given, with functions for writing in the console etc.
Use '\b'
. It erases one character, and the cursor moves back:
std::cout << "nawaz"; //screen shows : nawaz
std::cout << '\b'; //'z' is erased, now screen shows : nawa
do {
cout<<"\b"<<num--;
}
while ( num >0 );
Depends on the type of terminal you're using, you could use the escape codes to control it.
For Windows, there are also API functions, if I remember correctly.
精彩评论