C++:char test[100] vs array<char, 100> vs string

标签 c++

如果我有一个我知道长度不变的字符串,我应该使用什么?

char test[100]
std::array<char, 100> test
std::string test

谢谢!

最佳答案

答案在问题中:

If I have a string ...

如果你有一个字符串,使用std::string。除非您有未提及的非常具体的要求。

关于C++:char test[100] vs array<char, 100> vs string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33103650/

相关文章:

c++ - 如何默认构造迭代器的value_type作为函数中的默认参数?

c++ - std::condition_variable::在C++中等待

c++ - 带有 volatile 的 push_back 与 emplace_back

c++ - 对已定义方法的 undefined reference , header 中的声明与源匹配

c++ - 如何在线程中关闭QWebSocket?

c++ - C 字符串与带有类成员函数的字符串类语法

c# - MFC 和 C# 中的信号量、临界区、互斥量示例

C++11: move 操作会改变地址吗?

c++ - 如何忽略前 50 秒的信号?

python - 如何在 Cython 中构建 iostream 对象(例如 cout)并将其传递给 C++ 函数?