HOW to change value of a number present in a string

string: this is a 79 pc
output that i want: this is a 200 pc
echo "this is a 79 pc" | sed s/79/200/

That, obviously, is not C++ but it gives the requested result.

With C++ string you would first try to locate the substring that you want to change:
http://www.cplusplus.com/reference/string/string/find/
and then (if found) replace it with new substring:
http://www.cplusplus.com/reference/string/string/replace/
Topic archived. No new replies allowed.