Junior — Senior
Escaping a given character in a string
livecode
Task condition
It is necessary to implement a function that takes a string and a character, and returns a new string in which each occurrence of the specified character is preceded by a backslash, i.e., the character is "escaped". The function should work without modifying the original string.
std::string mark_char(const std::string& s, char ch) {
// implement
}
Example: Input: "a:b:c", character ':' → Output: "a\:b\:c"