Thursday, November 16, 2006

Find And Replace in C++

I was searching for an easiest way to find and replace in c++. This works amazing ..

Try..

std::string s = " dhanesh is not great ";

string s_toreplace = "not";

string s_replace = "very";

cout<<s<<std::endl;

std::string::size_type idx = -1;

while((idx = s.find(s_toreplace, idx+1)) != std::string::npos)

s.replace(idx, strlen(s_toreplace.c_str()), s_replace);

cout<<s<<std::endl;


Monday, November 06, 2006

Finally My Blog for Literature [Ninakkay Matram]

Guys and Gals,

If u dare .. Have a look .. No comments ..!