> For the complete documentation index, see [llms.txt](https://anton-veselskyi.gitbook.io/codding-problems-solutions/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://anton-veselskyi.gitbook.io/codding-problems-solutions/codewars/6-kyu/backspaces-in-string.md).

# Backspaces in string

## [Backspaces in string](https://www.codewars.com/kata/5727bb0fe81185ae62000ae3)

Assume `"#"` is like a backspace in string. This means that string `"a#bc#d"` actually is `"bd"`

Your task is to process a string with `"#"` symbols.

## Examples

```
"abc#d##c"      ==>  "ac"
"abc##d######"  ==>  ""
"#######"       ==>  ""
""              ==>  ""
```

## Solutions

### 🧠 C++

```cpp
std::string cleanString(const std::string &s)
{
    std::string res = "";
    for(int i = 0; i < s.size(); i++)
    {
      if(s[i] == '#')
        res.pop_back();
      else
        res.push_back(s[i]);
    }

    return res;
}
```
