How to erase (delete) the character before last from a string in C++

1 Answer

0 votes
#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

int main()
{
	string s("c++ programming");

	s.erase(s.end() - 2);

	cout << s << endl;

	return 0;
}

/*
run:

c++ programmig

*/

 



answered May 9, 2018 by avibootz

Related questions

2 answers 225 views
1 answer 197 views
1 answer 163 views
2 answers 187 views
1 answer 187 views
2 answers 267 views
...