Question
1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
string str ("steve jobs is legend");
7.
string::iterator it;
8.
str.erase (str.begin()+ 5, str.end()-7);
9.
cout
What is the output of this program?
1.
#include
2.
#include
3.
using namespace std;
4.
int main ()
5.
{
6.
string str ("steve jobs is legend");
7.
string::iterator it;
8.
str.erase (str.begin()+ 5, str.end()-7);
9.
cout
Answer: Option B
Was this answer helpful ?
In this program, We are leaving the first 5 characters and last 7 characters and we are erasing
the remaining the characters.
Output:
$ g++ stri3.cpp
$ a.out
steve legend
Was this answer helpful ?
Submit Solution