【发布时间】:2021-12-09 07:36:39
【问题描述】:
const char *attribute[] =
{"abc","efg","hij","lmn","opq","rst","uvw","Xyz"};
想在上面的数组中找到“lmn”的布尔值和位置。
【问题讨论】:
-
或者,如果您的编译器进行常量字符串优化并且文字
"lmn"的所有实例都将相同(很可能),那么只需简单的std::find(begin(attributes), end(attributes), "lmn")?或者完全停止对任何类型的字符串使用char*,而只使用std::string?