handling backspace with string

Started by
1 comment, last by Jaggy 20 years ago
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.
Advertisement
How about:

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.
Thanks for the reply. I didn''t have a .left, but it put me on the right track to something that did work:

getName.resize(getName.size() - 1);

This topic is closed to new replies.

Advertisement