How to replace character 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(4, 1, "X");

	cout << s << endl;

	return 0;
}

/*
run:

c++ Xrogramming

*/

 



answered May 9, 2018 by avibootz
...