Redian新闻
>
EB1a Approved with background information
avatar
EB1a Approved with background information# Immigration - 落地生根
c*e
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)
avatar
h*k
3
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)

avatar
u*e
4
Super!
Thanks a lot!
Is this the so called "Shafa"?
avatar
d*e
5
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)

avatar
w*r
6
A very helpful good post.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。