#include #include #include void main() { // Setup const char *pszInput = "Drivers (*.xxx)|*.xxx|All Files (*.*)|*.*||"; std::string strInputWithCharArray = pszInput; std::string strInputWithCharPointer = pszInput; char szFormat[ 8 ]; char *pszFormat = szFormat; // Setup the format string. strcpy( szFormat, "abcde" ); szFormat[ 3 ] = '\0'; // Inserting null character in place of 'd'. boost::algorithm::ireplace_all( strInputWithCharArray, "xxx", szFormat ); boost::algorithm::ireplace_all( strInputWithCharPointer, "xxx", pszFormat ); // Output the results. std::cout << "The results with character array as the Format parameter..." << std::endl; std::cout << strInputWithCharArray << std::endl; std::cout << strInputWithCharArray.c_str() << std::endl; std::cout << std::endl; std::cout << "The results with character pointer as the Format parameter..." << std::endl; std::cout << strInputWithCharPointer << std::endl; std::cout << strInputWithCharPointer.c_str() << std::endl; } //{ // // Displaying the characters one-by-one. // //const int nLengthInputWithCharArray = strInputWithCharArray.length(); // //for( int idx = 0; idx < nLengthInputWithCharArray; ++idx ) // //{ // // std::cout << strInputWithCharArray[ idx ]; // // std::cout << " : "; // // std::cout << static_cast< int >( strInputWithCharArray[ idx ] ); // // std::cout << std::endl; // //} // // char ch; // std::cin >> ch; //}