我在操作上有问题string,首先考虑这些string:
string s1 = "Graveworm";
string s2 = "Motörhead"; //the best of the best, just to say...
正如你所看到的,他们每个人都有 9 chars,是的.. 但是没有......因为当我pop_back()有一个像“é”这样的重音字母时,我必须有pop_back()两个chars。
所以现在,有一种方法可以知道我有多少char(s)pop_back(),记住s1并s2写在代码中。
注意 :: 在写这个问题时,我想到了一种可能的方法:获取字符串的大小并逐个删除字符,只要大小没有减少一个;好吧,我试过这个:
if(s->size()>0){
int size = s->size();
for(i=size; i > size-1 ;i--){
s->pop_back();
}
没有按预期工作