String an bestimmter Stelle teilen

Post Reply
Message
Author
BB

String an bestimmter Stelle teilen

#1 Post by BB »

wie kann ich einen string an einer beliebigen Stelle teilen

zBsp. string = "abcdefghij"

dann soll string1 = "abcd" und string2 = "efghij" sein

danke

tkortkamp
Posts: 143
Joined: 08. Apr 2001 22:56
Location: Bremen

Re: String an bestimmter Stelle teilen

#2 Post by tkortkamp »

Nichts leichter als das:
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
std::string str = "abcdefghij";
std::string str1 = str.substr(0, 4); // = "abcd"
std::string str2 = str.substr(4, str.length()); // = "efghij"
</font><hr></pre></blockquote>

c ya,
Tobias
Last edited by tkortkamp on 11. Jul 2002 0:01, edited 1 time in total.
dude i'm pretty damn sure you could script somebody back to life

Post Reply