string::pop_back

void pop_back();//弹出最后一个字符

#include <string>
#include <iostream>

using namespace std;
int main()
{
string str("hello world!");
str.pop_back();
cout << str << endl;
return 0;
}

原文地址:https://www.cnblogs.com/xpylovely/p/12177955.html