C ++:char test [100] vs array< char,100> vs字符串 [英] C++: char test[100] vs array<char, 100> vs string

查看:158
本文介绍了C ++:char test [100] vs array< char,100> vs字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

谢谢!




如果我有一个 string ... ...




如果您有字符串,请使用 std :: string 。除非你有非常具体的要求,你没有提到。


If I have a string that I know will be of constant length, what should I use?

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

Thanks!

解决方案

The answer is in the question:

If I have a string ...

If you have a string, use std::string. Unless you have very specific requirements that you have not mentioned.

这篇关于C ++:char test [100] vs array&lt; char,100&gt; vs字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆