| View previous topic :: View next topic |
| Author |
Message |
puzzlecracker Guest
|
Posted: Wed Sep 28, 2005 1:24 am Post subject: I need a function that extracts all string from /this config |
|
|
let's say I have
string str=etc/temp/erase;
I need to extract
etc
temp
erase
is there a quick function in c++ for that with me having to write one?
THanks
|
|
| Back to top |
|
 |
puzzlecracker Guest
|
Posted: Wed Sep 28, 2005 1:38 am Post subject: Re: I need a function that extracts all string from /this co |
|
|
puzzlecracker wrote:
| Quote: | let's say I have
string str=etc/temp/erase;
I need to extract
etc
temp
erase
is there a quick function in c++ for that with me having to write one?
THanks
|
string temp="alex/paul/james";
int n, prev=5;
if((n=temp.find('/',prev))!=string::npos){
cout<
prev=n+1;
}
why doesnt this work?
|
|
| Back to top |
|
 |
Jon Slaughter Guest
|
Posted: Wed Sep 28, 2005 2:04 am Post subject: Re: I need a function that extracts all string from /this co |
|
|
"puzzlecracker" <ironsel2000 (AT) gmail (DOT) com> wrote
| Quote: |
puzzlecracker wrote:
let's say I have
string str=etc/temp/erase;
I need to extract
etc
temp
erase
is there a quick function in c++ for that with me having to write one?
THanks
string temp="alex/paul/james";
int n, prev=5;
if((n=temp.find('/',prev))!=string::npos){
cout<
prev=n+1;
}
why doesnt this work?
|
|
|
| Back to top |
|
 |
Jon Slaughter Guest
|
Posted: Wed Sep 28, 2005 2:16 am Post subject: Re: I need a function that extracts all string from /this co |
|
|
"puzzlecracker" <ironsel2000 (AT) gmail (DOT) com> wrote
| Quote: |
puzzlecracker wrote:
let's say I have
string str=etc/temp/erase;
I need to extract
etc
temp
erase
is there a quick function in c++ for that with me having to write one?
THanks
string temp="alex/paul/james";
int n, prev=5;
if((n=temp.find('/',prev))!=string::npos){
cout<
prev=n+1;
}
why doesnt this work?
|
Try this:
string temp="alex/paul/james";
int n=0, prev=0;
while((n = temp.find('/', prev)) <= string::npos)
{
cout << temp.substr(prev, n-prev) << endl;
prev=n+1;
}
Jon
|
|
| Back to top |
|
 |
|