#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;
}
Code Example |
---|
Cpp :: elixir update map |
Cpp :: c++ print vector without loop |
Cpp :: conditional operator in cpp |
Cpp :: wine linux |
Cpp :: c++ open file |
Cpp :: how to string to integer in c++ |
Cpp :: print float number with only four places after the decimal point in c++ |
Cpp :: c++ hours minutes seconds |
Cpp :: http.begin arduino not working |
Cpp :: sort stl |
Cpp :: tuple c++ |
Cpp :: convert all characters in string to uppercase c++ |
Cpp :: C++ Volume of a Sphere |
Cpp :: c++ vector loop delete |
Cpp :: convert binary string to int c++ |
Cpp :: vector.find() |
Cpp :: sieve cpp |
Cpp :: C++ array sort method |
Cpp :: Parenthesis Checker using stack in c++ |
Cpp :: ubuntu dotnet core install |
Cpp :: binary representation c++ |
Cpp :: C++ structure (Struct) |
Cpp :: how to delete a file in cpp |
Cpp :: function c++ |
Cpp :: c++ string size |
Cpp :: for loop f# |
Cpp :: hello world in c/++ |
Cpp :: string split by space c++ |
Cpp :: fizzbuzz c++ |
Cpp :: c define |