c**********e 发帖数: 2007 | 1 【 以下文字转载自 Programming 讨论区 】
发信人: careerchange (Stupid), 信区: Programming
标 题: How to convert string to string array (or vector)
发信站: BBS 未名空间站 (Mon Sep 13 19:18:21 2010, 美东)
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) | h**k 发帖数: 3368 | 2 MyStringArray[0] = MyString.substring(0, MyString.find(';') );
MyString.erase(0, MyString.find( ';' ) );
a
【在 c**********e 的大作中提到】 : 【 以下文字转载自 Programming 讨论区 】 : 发信人: careerchange (Stupid), 信区: Programming : 标 题: How to convert string to string array (or vector) : 发信站: BBS 未名空间站 (Mon Sep 13 19:18:21 2010, 美东) : 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)
| d**e 发帖数: 6098 | 3 google string tokenizer c++ 应该有收获
a
【在 c**********e 的大作中提到】 : 【 以下文字转载自 Programming 讨论区 】 : 发信人: careerchange (Stupid), 信区: Programming : 标 题: How to convert string to string array (or vector) : 发信站: BBS 未名空间站 (Mon Sep 13 19:18:21 2010, 美东) : 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)
|
|