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

后端 未结 7 971
闹比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:05

    1) You do not need to make space for the null terminator.
    2) capacity() tells you how much space the string has reserved internally. length() tells you the length of the string. You probably don't want capacity()

提交回复
热议问题