#include #include using namespace std; void splitstring(string str, string seperater, string &first, string &second) //will split a string into 2 { int i = (int)str.find(seperater); //find seperator if(i != -1) { int y = 0; if(!str.empty()) { while(y != i) { first += str[y++]; //creating first string } y = y+(int)seperater.length(); //jumping forward seperater length while(y != str.length()) { second += str[y++]; //creating second string } } } else { first = str; second = "NULL"; //if seperator is not there then second string == null } } void main() { stirng a, b, c; a.assign("Hello world!"); splitstring(a, " ", b, c); cout << "b = " << b << endl << "c = " << c << endl; //b == Hello //c == world! }