将以 null 结尾的 const char* 字符串数组转换为 std::vector< std::string >
我有一个 Visual Studio 2008 C++ 函数,其中给出了一个以 null 结尾的字符串数组 const char*
以及该数组中字符串数量的计数。
我正在寻找一种巧妙的方法将 const char*
数组转换为 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 也很好。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
像这样的东西?:
Something like this?:
试试这个:
Try this:
假设你的函数的签名无意中错误,你的意思是这样的吗?
Assuming that the signature of your function is inadvertently wrong, do you mean something like this?
我假设你的数组中的字符串是用 0 分隔的。
I assume in your array strings are separated by 0s.