C++ examples for STL:string
Inserts the characters "******" in the exact middle of a string.
#include <iostream> #include <string> int main(int argc, const char* argv[]) { std::cout << "Enter a string: "; std::string base;//www . java 2 s . c o m std::getline(std::cin, base); std::string insertStr = "******"; base.insert((base.length() / 2), insertStr); std::cout << "\nNew String:\n" << base << std::endl; return 0; }