std::string.resize() and std::string.length()

后端 未结 7 984
闹比i
闹比i 2020-12-11 23:51

I\'m relatively new to C++ and I\'m still getting to grips with the C++ Standard Library. To help transition from C, I want to format a std::string using printf

7条回答
  •  长情又很酷
    2020-12-12 00:18

    The std::string class takes care of the null terminator for you.

    However, as pointed out, since you're using vnsprintf to the raw underying string buffer (C anachronisms die hard...), you will have to ensure there is room for the null terminator.

提交回复
热议问题