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 for(int i = 1; i < argc; i++){
31 std::cerr << "|||| "<<argv[i]<<std::endl;
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] <<" does not exists." << std::endl;
69 //==========================================================================