#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();
Code Example |
---|
Cpp :: convert long int to binary string c++ |
Cpp :: copy 2 dimensional array c++ |
Cpp :: c++ loop through string |
Cpp :: c++ program to take input from user |
Cpp :: change abstract title name latex |
Cpp :: c++ vector sort |
Cpp :: c++ read image opencv in folder |
Cpp :: max function in c++ |
Cpp :: c++ declare variable |
Cpp :: how to convert int to std::string |
Cpp :: scan line in c++ |
Cpp :: print vector of vector c++ |
Cpp :: iteraate through a vector |
Cpp :: c++ string contains |
Cpp :: binary file in c++ |
Cpp :: vector fin element c++ |
Cpp :: cpp Sieve algorithm |
Cpp :: How to pause a c++ program. |
Cpp :: splice string in c++ |
Cpp :: find max element in array c++ |
Cpp :: check if char in string c++ |
Cpp :: continue c++ |
Cpp :: c++ split string by several space |
Cpp :: c++ pi float |
Cpp :: C++ Area and Perimeter of a Rectangle |
Cpp :: overload of << c++ |
Cpp :: concatenate two vectors c++ |
:: find kth max and min element in an array |
Cpp :: fizzbuzz c++ |
Cpp :: c define |