Can a std::string contain embedded nulls?

前端 未结 4 1534
臣服心动
臣服心动 2020-12-01 15:24

For regular C strings, a null character \'\\0\' signifies the end of data.

What about std::string, can I have a string with embedded null c

4条回答
  •  甜味超标
    2020-12-01 16:10

    Yes. A std::string is just a vector with benefits.

    However, be careful about passing such a beast to something that calls .c_str() and stops at the 0.

提交回复
热议问题