11 void replace( std::string& str,
12 const std::string& from,
13 const std::string& to )
16 string::size_type pos = str.find( from );
17 while ( pos != string::npos )
19 str.replace( pos, from.size(), to );
20 pos = str.find( from, pos+from.size()-1 );
27 //==========================================================================
28 int main(int argc, char **argv)
33 std::cerr << "usage : "<< argv[0] <<" fileIn \"FindString\" \"ReplaceString\"" << std::endl;
40 std::string findstring;
41 std::string replacestring;
47 replacestring = argv[3];
49 ffIn = fopen(fileIn.c_str(),"r");
52 fgets( strTmp , 255, ffIn );
54 if( feof(ffIn) && (lineStr.length()==1) ) {
56 replace( lineStr,findstring, replacestring );
62 std::cerr << "ERROR. File : "<< argv[1] <<" Not exists." << std::endl;
69 //==========================================================================