C++ fixed length string class?

前端 未结 10 1097
遇见更好的自我
遇见更好的自我 2020-12-17 17:56

Is there anything like this in Standard C++ / STL? Ideally it should be constructed like

fstring s = fstring(10);

I need to sometimes cons

10条回答
  •  一向
    一向 (楼主)
    2020-12-17 18:28

    If I understand you correctly, you don't want to use std::string because you're worried it might silently expand on you. I see a couple of options:

    1. Use a raw C-style string and the functions from cstdio that take a length argument (e.g., fgets).

    2. Use a std::vector.

提交回复
热议问题