[c++] 문자열에서 특정 문자열 제거하는 방법

#include #include

int main() { std::string str = “Hello, World!”; std::string substr = “, “;

size_t pos = str.find(substr);
if (pos != std::string::npos) {
    str.erase(pos, substr.length());
}

std::cout << str; // Output: "Hello World!"

return 0; } ```

위의 예시 코드는 C++를 사용하여 문자열에서 특정 부분을 제거하는 방법을 보여줍니다. find 함수를 사용하여 부분 문자열의 위치를 찾고, erase 함수를 사용하여 해당 부분을 제거합니다.

자세한 내용은 cplusplus.com을 참조해 주세요.