0
How to edit a string
An example of this would be if I could always change the first letter of an inputted string to N or something
4 Answers
+ 2
string s="would" ;
s[0]='c';
s="could";
You mean like this?
0
String is an array of char, you can change letters using positions like:
string str = "test";
str[0] = 'b';
cout << str; //Output --> best;
str[2] = 'a';
cout << str; //Output --> beat;
Or for edit a string by replacing more then one char, you can use member function replace(),
See this example
http://www.cplusplus.com/reference/string/string/replace/