How to replace substring in string with 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 = s.replace(0, 3, "java ");

	cout << s << endl;

	return 0;
}

/*
run:

java  programming

*/

 



answered May 9, 2018 by avibootz

Related questions

1 answer 209 views
1 answer 123 views
2 answers 150 views
150 views asked Jan 5, 2021 by avibootz
...