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

1 c++

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

char test[100]
std::array<char, 100> test
std::string test
Run Code Online (Sandbox Code Playgroud)

谢谢!

eer*_*ika 8

答案在于问题:

如果我有一个字符串 ......

如果你有一个字符串,请使用std::string.除非你有非常具体的要求,否则你没有提到.