(platform-espressif32)When I assign data with type of char* to wifi_config_t.sta.ssid and wifi_config_t.sta.password,wifi can't be connected

It didn’t work like this:

Part of code like this:

uint16_t to_connect_wifi(const char* ssid, const char* pwd)
{
    wifi_config_t wifi_config;
    memset(wifi_config.sta.ssid,0,sizeof(wifi_config.sta.ssid));
    memset(wifi_config.sta.password,0,sizeof(wifi_config.sta.password));
    strcpy((char*)(wifi_config.sta.ssid),ssid);
    strcpy((char*)(wifi_config.sta.password),pwd);
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config1));
    esp_wifi_connect();
}

but it worked if i used this code

#define EXAMPLE_WIFI_SSID		"XXX"
#define EXAMPLE_WIFI_PASS		"XXXXXX"

wifi_config_t wifi_config1 = {
        .sta = {
            .ssid = EXAMPLE_WIFI_SSID,
            .password = EXAMPLE_WIFI_PASS,
        },
    };

Actually both of two situation the wifi_config has the same value:

I print the wifi_config like this:

    uint8_t i = 0;
    for(i = 0; i < 32; i++)printf("%c", wifi_config.sta.ssid[i]);
    printf("\n");
    for(i = 0; i < 64; i++)printf("%c", wifi_config.sta.password[i]);
    printf("\n");
    for(i = 0; i < 32; i++)printf("%c", wifi_config1.sta.ssid[i]);
    printf("\n");
    for(i = 0; i < 64; i++)printf("%c", wifi_config1.sta.password[i]);
    printf("\n");

(to make code brief, I omitted some bracket)

It’s outputs:

WIFI�������������������������
123456789��������������������������������������������������������
WIFI�������������������������
123456789��������������������������������������������������������

// � is a nan character

But since this structure is allocated on the stack, all other fields are still filled with random values. What happens with

uint16_t to_connect_wifi(const char* ssid, const char* pwd)
{
    wifi_config_t wifi_config;
    memset(&wifi_config ,0,sizeof(wifi_config));
    strcpy((char*)(wifi_config.sta.ssid),ssid);
    strcpy((char*)(wifi_config.sta.password),pwd);
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
    esp_wifi_connect();
}

?

Yeah,actually I’ve found that after the structure is allocated, the data in it was random values,so I used the memset to set the value.
"What happens with it " :
The wifi was waiting to be connected, and it keeps this state, no erro and no change:

I (620) wifi_init: tcpip mbox: 32
I (630) wifi_init: udp mbox: 6
I (630) wifi_init: tcp mbox: 6
I (630) wifi_init: tcp tx win: 5744
I (640) wifi_init: tcp rx win: 5744
I (640) wifi_init: tcp mss: 1440
I (650) wifi_init: WiFi IRAM OP enabled
I (650) wifi_init: WiFi RX IRAM OP enabled
I (660) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (760) wifi:mode : sta (78:e3:6d:17:3f:e4)
I (760) wifi:enable tsf