由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to convert string to string array (or vector)
相关主题
有些人练java走火入魔,急需吃药哪儿有经典的C++ programing 习题集嘛?
问个c++问题Question about
诡异的异常处理C++ string类输入数据的问题
(char **)返回值怎么用SWIG包成Python list (of stringswhitespace 问题
C++ 两个project enum value名冲突C++ Strategies and Tactics 书上一个问题求助
天,如何能让程序转得快点?有包子。抠字眼:assignment and initialize in C++
i +++ j再问两个C++问题
一个sql问题:怎样实现 (((a1*10)+a2)*10+a3)*10 ...问个C++的String问题
相关话题的讨论汇总
话题: string话题: convert话题: value2话题: array
进入Programming版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
It looks that`in Java, there is a function Split which convert a string to a
string array. I wonder if we could do the same in C++. How to do the
conversion?
string MyString = "value1;value2;value3;value4;"
string[] MyStringArray = MyString.Split(';');
MyStringArray[0] (would give value1)
MyStringArray[1] (would give value2)
etc......
g*****g
发帖数: 34805
2
The underlying code in Java is using regex. There's probably C++ regex
package doing that too.

a

【在 c**********e 的大作中提到】
: It looks that`in Java, there is a function Split which convert a string to a
: string array. I wonder if we could do the same in C++. How to do the
: conversion?
: string MyString = "value1;value2;value3;value4;"
: string[] MyStringArray = MyString.Split(';');
: MyStringArray[0] (would give value1)
: MyStringArray[1] (would give value2)
: etc......

d****p
发帖数: 685
3
#include
std::vector tokens;
boost::split(tokens, "value1;value2;value3;value4", boost:is_any_of(";");
// now tokens[i] = "value"

a

【在 c**********e 的大作中提到】
: It looks that`in Java, there is a function Split which convert a string to a
: string array. I wonder if we could do the same in C++. How to do the
: conversion?
: string MyString = "value1;value2;value3;value4;"
: string[] MyStringArray = MyString.Split(';');
: MyStringArray[0] (would give value1)
: MyStringArray[1] (would give value2)
: etc......

1 (共1页)
进入Programming版参与讨论
相关主题
问个C++的String问题C++ 两个project enum value名冲突
问一个sort的问题天,如何能让程序转得快点?有包子。
C++一个string的小问题i +++ j
C++ string to int Problem一个sql问题:怎样实现 (((a1*10)+a2)*10+a3)*10 ...
有些人练java走火入魔,急需吃药哪儿有经典的C++ programing 习题集嘛?
问个c++问题Question about
诡异的异常处理C++ string类输入数据的问题
(char **)返回值怎么用SWIG包成Python list (of stringswhitespace 问题
相关话题的讨论汇总
话题: string话题: convert话题: value2话题: array