Replace char in string with some string inplace

前端 未结 4 1616
刺人心
刺人心 2021-01-14 16:16


i want to replace a character in the string with a string. can i do it in-place? As the new string has length greater than original string.Question is that can i do with

4条回答
  •  遥遥无期
    2021-01-14 16:43

    I think you misundertand C++ std::string. It can actually change the string length dynamically. In internally does heap allocations, and will grow the buffer if necessary.

提交回复
热议问题