splice string in c++
#include <iostream>
#include <string>
int main() {
std::string originalString = "Hello, World!";
// Find the position to start splicing
size_t startPosition = originalString.find("World");
// Check if the substring is found
if (startPosition != std::string::npos) {
// Length of the substring to be spliced
size_t substringLength = 5;
// Splice the string
originalString.erase(startPosition, substringLength);
// Output the modified string
std::cout << originalString << std::endl;
}
return 0;
}