strange question, need some help, thanks

My board is ESP8266.
In the smartConfig() function, get the ssid and password, print them(display the right infomation i want) and then pass the value to the external variables.
In the loop function, print the ssid, but the result is something like "??".

so what is the problem, i have spent much time on it. thank you very much if you can give me some information about it.

here is my code

#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
const char* ssid;
const char* password;

bool smartConfig(){
    WiFi.mode(WIFI_STA);
    Serial.println("\r\nWait for Smartconfig");
    WiFi.beginSmartConfig();
    while (1){
        delay(500);
        Serial.println("waiting for smartconfig");
        if (WiFi.smartConfigDone()){
            delay(1000);
            ssid= WiFi.SSID().c_str();
            password = WiFi.psk().c_str();
            Serial.println(ssid); // the right result like "mywifi"
            Serial.println(password); // the right result like "mypasswd"
             Serial.println("SmartConfig Success");
            break;
        }
    }
return true;
}
 
 
void setup() {
    Serial.begin(115200);
    Serial.println("");
    delay(1000);
    smartConfig();
    Serial.println(ssid);
    Serial.println(password);
}
 
 
void loop() {
    delay(1000);
    Serial.println(ssid);// not the "mywifi",but "?????"
    Serial.println(password);//not the "mypasswd",but "?????"
}

i just post the simplified code, delete the unrelated.

the WiFi.SSID() return "A String containing the SSID the WiFi shield is currently connected to"

here is the link WiFi - Arduino Reference

the strange thing is that, in the smartConfig function, the print result is right, but the loop function is not

ssid = WiFi.SSID();// error can not convert String to const char*.

the strcpy works, thank you very much!!!