Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: Leo the 28C (by Sulfurik)
Hello everyone! :-D
OK, I've came across many functions for this, but none works! I need one that works like this:StringSplit(string str, string delim, vector<string> results)
Either with strings or char arrays, doesn't matter... anyone know? Thanks! ;-)
PS: I need it to work under GCC with no MFC or VC++ please! ;-)
http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cxRuffle Mayo says ROFLMAO! :D

Well... something like making "hello world" into an array of "hello" and "world"... Do you know? Thanks! ;-)
http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cxRuffle Mayo says ROFLMAO! :D

If I understand what you mean correctly, something like that should work:
StringSplit(string str, string delim, vector<string> results)
{
int cutAt;
while( (cutAt = str.find_first_of(delim)) != str.npos )
{
if(cutAt > 0)
{
results.push_back(str.substr(0,cutAt));
}
str = str.substr(cutAt+1);
}
if(str.length() > 0)
{
results.push_back(str);
}
}This one splits the string str by any char appears in delim, not including this char. For instance, the call SplitString( "abcdefghabcd", "ade", v);
will put in v the strings "bc" "fgh" "bc".

Hmm... I found something else already, but your function looks more efficient... I'll try it and then I'll tell you if it worked, much thanks! ;-)
http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cxRuffle Mayo says ROFLMAO! :D

![]() |
C++ int statement help
|
Get currently logged on u...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |