954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using '\b' in visual c++

Hi,
I'm an absolute beginner in Visual C++ (Express Edition 2010). I've just been trying out this very simple program, and I can't get to use the '\b' tag like I did when I used Turbo C++ v4.5. The cursor moves backwards, but the text does not get erased, as it did with Turbo C++.
The code is:

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	cout<<"Hello";
	cout<<"\b\b";
	_getch();
}

The output is
Hello
(Underline represents cursor position).
What am I doing wrong? Any help would be appreciated.

aashishsatya
Newbie Poster
5 posts since Jan 2012
Reputation Points: 6
Solved Threads: 0
 

I've never used Turbo C++, but you can get similar results by moving the cursor backwards, and then replacing the letters with white spaces.

std::cout << "2 + 2 = 4\b5" << std::endl; // replaces 4 to 5
std::cout << "erase\b\b  " << std::endl; // replaces "se" with white spaces
LRRR
Junior Poster in Training
55 posts since Dec 2011
Reputation Points: 22
Solved Threads: 15
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: