将空终止的const char *字符串的数组转换为std :: vector < std :: string> [英] converting an array of null terminated const char* strings to a std::vector< std::string >
本文介绍了将空终止的const char *字符串的数组转换为std :: vector < std :: string>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Visual Studio 2008 C ++函数,其中给出一个空终止的字符串数组 const char *
和该数组中字符串数的计数。
I have a Visual Studio 2008 C++ function where I'm given an array of null-terminated strings const char*
and a count of the number of strings in that array.
我正在寻找一种聪明的方法将 const char *
的数组转换为 std :: vector< std :: string>
I'm looking for a clever way of turning an array of const char*
in to a std::vector< std::string >
/// @param count - number of strings in the array
/// @param array - array of null-terminated strings
/// @return - a vector of stl strings
std::vector< std::string > Convert( int count, const char* array[] );
Boost很好,STL很好。
Boost is fine, STL is fine.
感谢您,
PaulH
Thanks, PaulH
推荐答案
?:
vector< string > ret( array, array + count );
这篇关于将空终止的const char *字符串的数组转换为std :: vector < std :: string>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文