阅读量:126
在C++中创建字符串数组可以采用以下方法:
- 使用字符数组:可以使用字符数组来创建字符串数组。例如:
char strArray[][20] = {"Hello", "World", "C++"};
- 使用std::vector:可以使用std::vector来创建动态大小的字符串数组。例如:
#include
#include
std::vector strArray = {"Hello", "World", "C++"};
- 使用std::array:可以使用std::array来创建固定大小的字符串数组。例如:
#include
#include
std::array strArray = {"Hello", "World", "C++"};
这些方法都可以用来创建字符串数组,具体选择哪种方法取决于需求和使用场景。