Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

C++ String Replace

DZone's Guide to

C++ String Replace

·
Free Resource
// description of your code here


string replace(const string& str,const &string from,const string & to)
{
        string::size_type pos=string::npos;
        if((pos=str.find(from))!=string::npos)
        {
                return str.replace(pos,from.length(),to);
        }
        else
                return str;
}
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}