9 //==========================================================================
10 void replace(std::string& str,
11 const std::string& from,
12 const std::string& to )
14 std::string::size_type pos = str.find( from );
15 while ( pos != std::string::npos )
17 str.replace( pos, from.size(), to );
18 pos = str.find( from, pos+from.size()-1 );
21 //==========================================================================
24 //==========================================================================
25 int main(int argc, char **argv)
30 std::cerr << "usage : "<< argv[0] <<" fileIn \"FindString\" \"ReplaceString\"" << std::endl;
37 std::string findstring;
38 std::string replacestring;
44 replacestring = argv[3];
46 ffIn = fopen(fileIn.c_str(),"r");
49 fgets( strTmp , 255, ffIn );
51 if( feof(ffIn) && (lineStr.length()==1) ) {
53 replace( lineStr,findstring, replacestring );
59 std::cerr << "ERROR. File : "<< argv[1] <<" does not exists." << std::endl;
66 //==========================================================================