How to insert a string into other string in C++

1 Answer

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

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

int main()
{
	string s1 = "c c++ java";
	string s2 = "php";

	s1.insert(6, s2 + " ");

	cout << s1 << endl;

	return 0;
}


/*
run:

c c++ php java

*/

 



answered May 28, 2018 by avibootz

Related questions

1 answer 169 views
1 answer 197 views
2 answers 216 views
1 answer 159 views
159 views asked Apr 20, 2018 by avibootz
1 answer 218 views
218 views asked May 9, 2021 by avibootz
1 answer 201 views
3 answers 185 views
...