Hi,
I am writing a C++ program to "find and replace" strings. Following is the code:
void pt::replace()
{
string str( textpath );
string searchString( "\" );
string replaceString( "\\" );
assert( searchString != replaceString );
string::size_type pos = 0;
while ( (pos = str.find(searchString, pos)) != string::npos ) {
str.replace( pos, searchString.size(), replaceString );
pos++;
}
cout << str << endl;
}
Whenever I type any text inside searchString(), it works fine but problem arises when I type "\" inside search or replace function. I think I need some type of datatype conversion. Please help me on this.