c_str() not working on ESP8266WiFi.h

Hi everybody, i am programming the ESP8266 with the library ESP8266WiFi.h. I am trying to set the ssid and password through the serial monitor, but when i convert the string of the ssid and password to char* with the c_str() the ESP doesn’t connect to the WIFI. Also, if i print the result ssid and password it prints well, it’s just when the ESP tries to connect to the WIFI:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

char Dato;
String Datos = "";
String Resultado = "";
void setup () {
 
  Serial.begin(9600);
  Serial.print("No conectado");
  WiFi.disconnect(true);
}
 
void loop() {
  if(WiFi.status() != WL_CONNECTED){
    while(Serial.available()){
      Dato = Serial.read();
      Datos += Dato;
    }
    if(Datos.length() > 3){
      Serial.print("\nConectando a la red...");
      //Serial.print(Split(Datos, ';', 0).c_str());
      //WiFi.begin(Split(Datos, ';', 0).c_str(), Split(Datos, ';', 1).c_str());
      //WiFi.begin("fake ssid", "fake pass");
      while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
      }
      Serial.print("Conectado");
    }
  }
  else{
    HTTPClient http;
    http.begin("http://send request");
    int httpCode = http.GET();
    if (httpCode > 0) {
      String payload = http.getString();
      Serial.println(payload);
    }
    http.end();
  }
  delay(1000);
}


int found = 0;
int strIndex[] = { 0, -1 };
int maxIndex;
String getValue(String data, char separator, int index)
{
  found = 0;
  strIndex[0] = 0;
  strIndex[1] = -1;
  maxIndex = data.length() - 1;

  for (int i = 0; i <= maxIndex && found <= index; i++) {
    if (data.charAt(i) == separator || i == maxIndex) {
      found++;
      strIndex[0] = strIndex[1] + 1;
      strIndex[1] = (i == maxIndex) ? i + 1 : i;
    }
  }
  return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
}

String Split(String cadena, char caracter, int posicion){
  String Sector = "";
  int Pos = 0;
  for(int i = 0; i < cadena.length(); i++){
    if(cadena[i] == caracter){
      if(Pos == posicion){
        return (Sector); 
      }
      else{
        Pos++;
      }
      Sector = "";
    }
    else{
      Sector+=cadena[i]; 
    }
  }
  return (Sector);
}

As you can see, on the line 22, 23 and 24 i have commented the 3 cases:

The Nº1 (line 22): i print on the serial monitor the split and the conversion with c_str(), i prints all fine so no problem with that.

The Nº2 (line 23): i tried to put the same conversion as line 22 bvut in the begin of the ESP to connect to the WIFI, here is the problem, it just doesn’t connect.

The Nº3 (line 24): This is the normal connection, it works fine.

Son anybody has an idea of what can be the problem there? Thank you so much!

Now i know what was the mistake, the NL & CR on the serial monitor, now works fine