How to insert char in a string with C++

3 Answers

0 votes
#include <iostream>
 
using namespace std;

int main() {
    string s = "PythonJavaPHPC++";
 
    s.insert(3, " ");
    cout << s;
}
 
 
 
/*
 
Pyt honJavaPHPC++
 
*/

 



answered Jan 15, 2020 by avibootz
0 votes
#include <iostream>
 
using namespace std;

int main() {
    string s = "PythonJavaPHPC++";
 
    s.insert(4, "W");
    cout << s;
}
 
 
 
/*
 
PythWonJavaPHPC++
 
*/

 



answered Jan 15, 2020 by avibootz
0 votes
#include <iostream>
  
using namespace std;
 
int main() {
    string s = "PythonJavaPHPC++";
  
    s.insert(5, 1, 'B');
    cout << s;
}
  
  
  
/*
  
PythoBnJavaPHPC++
  
*/

 



answered Jan 15, 2020 by avibootz

Related questions

1 answer 218 views
218 views asked May 9, 2021 by avibootz
1 answer 218 views
1 answer 225 views
1 answer 173 views
1 answer 126 views
...