split array of charachter into two part

Jul 14, 2009 at 1:38pm
is there a function that will split array of charachter in to two parts.

for example.

if we have a string "mashineGun" and we search for the string "mashine" that will
return the rest of the string in this case "Gun".


Jul 14, 2009 at 3:54pm
personaly i dont know (or i have a short memory) any functions that splits a char array

Maybe substr(int startindex,int count) could help you, but that works only for strings, however you are able to convert char array to string and vice versa

edit

like this:
1
2
3
string myString = "machineGun";
string SubStr1 = myString.substr(0,7); //SubStr1 = "machine"
string SubStr2 = myString.substr(7,3); //Substr2 = "Gun" 
Last edited on Jul 14, 2009 at 3:59pm
Jul 14, 2009 at 3:58pm
O.k thank you guys, i thaught that this function is maybe present in some library.
but I will do the programming :)
Topic archived. No new replies allowed.