int glen(char * x) { int r = 0; while ( *(x++) ) r++; return r; } // String : Entire string to search. // Check : Looks for this char // Returns c string up to *check's char. // TOFDO : Clean this up! int *split( char *string, char *check) { //Variables. char dash = check[0]; char *first; char *second; int len = glen( string ); int pos = -1; int r[2]; while ( string[pos++] != dash ); //Get memory. //char *n = malloc( o ); //C first = (char *)malloc( pos ); //C++ second = (char *)malloc( len -pos ); //C++ //Make sure it's not fucked ( windows thing :( ) memset( first, 0, pos ); //Get some memory. memset( second, 0, len - pos ); //Get some memory. //Loop through string for chars. for ( int i = 0; i < len; i++ ){ if ( i < pos ) first[i] = string[i]; else second[i-pos] = string[i]; } //set the ints to ints! r[0] = atoi( first ); r[1] = atoi( second ); //free our memory. free(first); free(second); return r; //EH } void main() { int *x = split( "40-231", "-" ); printf( "MATT PROG BY DYLAN JOHNSTON!\nFirst: %i\nSecond:%i\n", x[0], x[1] ); }