Input changes and cin

Hey people, got a question to ask regarding to user input with cin.

Below is a simple input code that reads and prints out.

1
2
3
4
5
6
int main(int argc, const char * argv[])
{
    string tt;
    cin >> tt;
    cout << tt << endl;
}


My problem is that, when a user inputs "123" (without the quotes) but then realize that he may have inputed wrong. Instead of using the backspace key, the user uses the arrow keys to move back to "2", and then change it to "4".
The print out should be "143" however, the result is "123\3574".

How may I fix this problem?
Thanks in advance
Last edited on
I think your code is correct, the problem is with your compiler, because it worked on VS2010.
If that's the case, then I shall try doing it on VS2010. Currently working with Xcode (because i'm on a mac atm...)

Thanks for trying it out
Topic archived. No new replies allowed.