#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 :: migration meaning |
Cpp :: C++ String Copy Example |
Cpp :: stl sort in c++ |
Cpp :: c++ call by reference |
Cpp :: delete dynamic array c++ |
Cpp :: clear qlayout |
Cpp :: c++ inherit from class template |
Cpp :: ue4 float to fstring |
Cpp :: fast way to check if a number is prime C++ |
Cpp :: is power of 2 |
Cpp :: how to use cout function in c++ |
Cpp :: what is thread in c++ |
Cpp :: c++ rand include |
Cpp :: how to read files in c++ |
Cpp :: power of two c++ |
Cpp :: 3d vector c++ resize |
Cpp :: memory leak in cpp |
Cpp :: how to find min of two numbers in c++ |
Cpp :: new c++ |
Cpp :: notepad++ |
Cpp :: creare array con c++ |
Cpp :: c++ compile to exe |
Cpp :: C++ Increment and Decrement |
Cpp :: cpp define function |
Cpp :: find substring in string c++ |
Cpp :: reverse an array in c++ stl |
Cpp :: heap buffer overflow in c |
Cpp :: pass map as reference c++ |
Cpp :: print hola mundo |
Cpp :: Syntax for C++ Operator Overloading |