char *ssids[20]; // Pointers to up to 20 SSID's
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
int n = min(WiFi.scanNetworks(), 20);
for (int i = 0; i < n; i++)
{
ssids[i] = WiFi.SSID(i).c_str();
}
}
This might work unless the WiFi library re-uses the space it allocated for the SSID String's. If you want the SSID's to be saved you will need to allocate space for them. The easiest method might be to use String:
String ssids[20]; // Room for up to 20 SSID's
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.disconnect();
int n = min(WiFi.scanNetworks(), 20);
for (int i = 0; i < n; i++)
{
ssids[i] = WiFi.SSID(i);
}
}