C++ Remove new line from multiline string

前端 未结 12 2283
暗喜
暗喜 2020-12-08 06:14

Whats the most efficient way of removing a \'newline\' from a std::string?

12条回答
  •  有刺的猬
    2020-12-08 06:49

    The code removes all newlines from the string str.

    O(N) implementation best served without comments on SO and with comments in production.

    unsigned shift=0;
    for (unsigned i=0; i

提交回复
热议问题