Need another way to get the phone number

Hi everybody. I need another way to get the phone number from this string : +CMT: "+00000000000","","15/03/15,23:18:04+04"

For now i'm using this code and it works but it consumes to much RAM.

if(strstr(data, "+CMT:")) { // get the phone number if the sms is displayed on Serial, not saved on SIM.
    input = "";
    delay(100);
    input += data;
    input_trimmed = input;
    
    if(input.length() == 47) { //if 11 chr number
      number = input_trimmed.substring(7, 20); // get the callers number.
    }
    else if (input.length() == 48) { //if 12 chr number (cheap simcards)
      number = input_trimmed.substring(7, 21); // get the callers number.
    }
    Serial.print(number);
  }

Amd I'm using the same method for:

if(strstr(data, "+CBC:")) {
    in= "";
    voltage = "0";
    in += data;
    in_trimm = in;
    voltage = in_trimm.substring(11, 15);
    Serial.print("Voltage: ");  Serial.println(voltage);
  }

I think i have the voltage and the phone number as strings. Must be another way to have them as char or something. Any information is apreciated. Thanks.

Use strlcpy

Thanks for your answer. I'm not a programmer. I have worked a lot of time to make this work. Now I want to add an sd card library to my code, but it fails because tha lack of ram memory. I never worked with strlcpy so I have no idea how to use it.

cry4brk: Thanks for your answer. I'm not a programmer. I have worked a lot of time to make this work. Now I want to add an sd card library to my code, but it fails because tha lack of ram memory. I never worked with strlcpy so I have no idea how to use it.

Google is your friend