delete last character in string c++ code example
Example 1: remove last character from string c++
st = myString.substr(0, myString.size()-1);
Example 2: remove or erase first and last character of string c++
str.pop_back(); // removes last /back character from str
str.erase(str.begin()); // removes first/front character from str
Example 3: delete one specific character in string C++
#include <algorithm>
str.erase(std::remove(str.begin(), str.end(), 'a'), str.end());
Example 4: remove last letter in string c++
#include <iostream>
#include <string>
str.resize(str.size() - 1);