Insert string to another string, remove characters, replace substring - C++ Data Type

C++ examples for Data Type:string

Description

Insert string to another string, remove characters, replace substring

Demo Code

#include <iostream> 
#include <string> 
using namespace std; 

int main() //w ww. j  a  v  a 2 s . co m
{ 
  string words = "Something interesting and bizarre"; 
  cout << words << endl; 

  words.insert(10, "seriously "); 
  cout << words << endl; 

  words.erase(19,16); 
  cout << words << endl; 

  words.replace(4, 5, "body"); 
  cout << words << endl; 

  return 0; 
}

Result


Related Tutorials