• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# handling backspace with string

## Recommended Posts

Jaggy    127
Hey there! My game is almost finished, but I''ve hit a problem while asking the user to add their name to the highscore table. I can get input, but I don''t know how to handle backspaces. I''m using WM_CHAR and I have so far:
...
else if(wParam == VK_BACK)
{
string getName = Game->getCurrentName();
Game->setCurrentName(getName);

/* Need something like
getName--;
or
getName[getName.size() - 1] = ''/0'';
*/

return 0;
}

I''m on the right lines somewhere I think but I just can''t figure out the syntax. I haven''t used string very much. Can anyone help? Thanks for reading, Jaggy.

##### Share on other sites
flukus    138

getName = getName.left(getname.size() - 1);

I''m not sure if left is the function name but there should be something similar in whichever string class you are using.