Friday 15 March 2013

Remove Punctuation At The End Of A String C++ -



Remove Punctuation At The End Of A String C++ -

how remove specific type of punctuation @ end of string? want remove "-" a.k.a. hyphens. want remove them @ end of string. thanks.

update: user christophe has provided solution using less c++11! code below:

for (int n=str.length(); n && str[--n]=='-'; str.resize(n));

try:

while (str.length() && str.back() == '-') str.pop_back();

c++

No comments:

Post a Comment