+ 2

How to delete the last character from the string ?

How to delete the last character (not /0) from the string ? if anyone can help, please answer it...

6th Sep 2018, 4:39 PM
Boo
Boo - avatar
7 Réponses
+ 1
6th Sep 2018, 5:56 PM
Dan Walker
Dan Walker - avatar
+ 4
https://code.sololearn.com/cJmsrBzQXK5S/?ref=app AdrenoLegend You can see code😎
6th Sep 2018, 5:47 PM
Rishabh
Rishabh - avatar
+ 3
The simplest way to do it in C++ is using pop_back(), like for vector: #include <string> std::string s = "text"; s.pop_back(); std::cout << s; // tex
6th Sep 2018, 7:23 PM
Viacheslav
+ 2
You haven’t mentioned which language you want help in; this is how to do this in python: a='hello' a=a[:-1] print(a) # returns ‘hell’
6th Sep 2018, 4:44 PM
Russ
Russ - avatar
+ 2
In that case, I can't help you, sorry. Try tagging your question with the language names and you may get a more prompt and better response.
6th Sep 2018, 5:00 PM
Russ
Russ - avatar
+ 1
if i want it in c++ and java , then ?
6th Sep 2018, 4:45 PM
Boo
Boo - avatar
0
Tind Did you learn all here? or from the internet, university, etc....? 😊
6th Sep 2018, 6:33 PM
Angelo Sorte
Angelo Sorte - avatar