what happens if you make a test program and print out the integer value of what you typed in fetched by getch() and test that by typing in backspace?
gotoxy and getch are windows tools, not c++ and not portable. If that is OK with you, there are additional windows tools like kbhit that I believe can tell you when special keys were hit, eg it can tell the diff between 9 and 9 from normal 9 vs numeric keypad 9, and it can tell you left shift vs right shift, and so on --- things that games use to map controls that do not matter when just typing. This may be what is required; I don't recall what getch does for some instances but I don't think it can trap shift/ctrl/backspace/escape/ and such (??).
For MS, _kbhit() simply indicates whether there are char(s) waiting in the input buffer for extraction. Often used before _getch() so that _getch() is non-blocking if no input available.
Thanks Seeplus, I am rusty with windows, what is the one that is similar to getch, keypress()? I have a dim memory of getting keys with something and comparing them to some lookup table windows provided, VK_ labeled values for like F1 / esc / stuff ?
does not matter, if getch() returns 8, that should == \b ... not sure what is broken here
by the way substring to knock a letter off a string is dreadful. use pop_back.
Sorry I can't help further as I only use Windows. Outside of standard C++ input, special keyboard input is non-standard and different for different OS/compilers.
$ ./a.out
127 - aka the backspace key
27 - aka the delete key, yes, you really need to deal with multiple key codes for some things
91
51
126
113 - aka 'q'