| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all, Im trying to write a calculator in visual c++. So far so good but i cant get the backspace key to work. I want it to delete the last number added to a string variable - any ideas.
|
|
#2
|
|||
|
|||
|
If your asking how to erase the last element in a string try this.
Code:
string strSample("Sample");
strSample.erase( strSample.size() - 1, 1 );
|
|
#3
|
|||
|
|||
|
can you not get a simple \b to work properly?
always works for me! |
|
#4
|
|||
|
|||
|
I GOT A REAL RELATED QUESTION
How do you delete the first and only first entery in a string?! |
|
#5
|
|||
|
|||
|
Is it a C++ string, a C char array or something else? Could you be more specific I don't understand what you mean by deleting an entry from a string.
-KM- |
|
#6
|
|||
|
|||
|
You guys should learn the Standard Template Library, it is and will be your best friend for a longtime. This is a good place to start. http://www.msoe.edu/eecs/ce/courseinfo/stl/
To answer your question to erase the first letter in the string do this. Code:
string strSample("Sample");
strSample.erase( 0, 1 ); // "ample"
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > C++ erasing parts of a string |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|