#include <iostream>
#include <string>
str.resize(str.size() - 1);
#include <iostream>
#include <string>
int main()
{
std::string str = "SAND_TWATI";
std::cout<<str<<std::endl;
str.pop_back();
for(int i = 0; i <str.size() ; i++)
{
std::cout<<str[i];
}
return 0;
}
string name = "My String";
// To remove First character
name.erase(name.begin());
// To remove Last character
name.pop_back();
std::cout << name << std::endl;
// Output : y Strin
st = myString.substr(0, myString.size()-1);
#include <iostream>
using namespace std;
int main()
{
string input;
cout<<“Enter a string : “<<endl;
cin >> input;
cout<<“Removed last character : “<<input.substr(0, input.size() - 1)<<endl;
}
#include <iostream>
using namespace std;
int main()
{
string s = "madara";
s.substr(0, s.size() - 1); //madar
//Another method: By resizing string
s = "uchiha";
s.resize(s.size()-1); //uchih
return 0;
}
st = myString.substr(0, myString.size()-1);
#include <iostream>
using namespace std;
int main()
{
string s = "madara";
s.substr(0, s.size() - 1); //madar
//Another method: By resizing string
s = "uchiha";
s.resize(s.size()-1); //uchih
return 0;
}
str.pop_back();