hi friends...
i have some doubt regarding the output at the console.
what we generally have is that the output is written on the console and the cursor moves always forward. But what if in some special case we want to back track the cursor a few characters of lines back and delete(i should say clear) two three characters at the console..

i know that cursor can be moved backward by outputting the scancode for backspace key..but it doesn't clears that character.. for example..
consider that the output written at the console is : This is a test program_ the underscore sign at the end denotes the cursor...
now if i output the scan code for backspace of do just cout<<"\b"; then the cursor will come under 'm'...anything output after that will overwrite 'm' but m was not cleared off when i output backspace so how to do that??

is it even possible??

Recommended Answers

All 4 Replies

So once you've backspaced (or even as you backspace) output a blank space:
cout << ' ';
And then back the cursor up again

isn't there any other more efficient way or direct way to do that...??

>isn't there any other more efficient way
How is that not efficient? You'll find that any solution consists of "go here and write this glyph", which is precisely what you're doing with printing a backspace and then a space.

>or direct way to do that...??
Standard C++ doesn't give you much control over the console. You should be thrilled that you can solve your problem without resorting to a non-portable solution.

by efficient way i didnt point to the complexity...just it was looking like playing with console...didn't look a good method...but as u are saying that that's the only way...then ok...i will do that only...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.