assigning a array value to a variable causes call of overloaded 'print(String*&)

I am learning to code in cpp.
the problem I am facing is the function i wrote returns array of strings. but when I assign variable I get an error saying:

#include "ESP8266WiFi.h"

#define BLINK_PERIOD 250
long lastBlinkMillis;
boolean ledState;

#define SCAN_PERIOD 5000
long lastScanMillis;

String* getWifiHotspots() {
  //  String* arr = new String[];
  String arr[100];
  Serial.print("Scan start ... ");
  int mn = WiFi.scanNetworks();
  for (int i = 0; i < mn; i++)
  {
    arr[i] = WiFi.SSID(i).c_str();
  }
  return arr;
}

void setup()
{
  Serial.begin(115200);
  Serial.println();

  pinMode(LED_BUILTIN, OUTPUT);

  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  delay(100);
}

void loop()
{
  long currentMillis = millis();

  // blink LED
  if (currentMillis - lastBlinkMillis > BLINK_PERIOD)
  {
    digitalWrite(LED_BUILTIN, ledState);
    ledState = !ledState;
    lastBlinkMillis = currentMillis;
  }

  // trigger Wi-Fi network scan
  if (currentMillis - lastScanMillis > SCAN_PERIOD)
  {
    WiFi.scanNetworks(true);
    Serial.print("\nScan start ... ");
    lastScanMillis = currentMillis;
  }

  // print out Wi-Fi network scan result uppon completion
  //  int n = WiFi.scanComplete();
  int n = WiFi.scanNetworks();
  if (n >= 0)
  {
    Serial.printf("%d network(s) found\n", n);
    String* results = getWifiHotspots();
    Serial.println(results);
    WiFi.scanDelete();
  }

How do get an array containg hotspot names like this :

 ['ESP8266', 'network18', 'Jio']

please help !

Double quotes, not single.

Returning an item from a function when that item was declared locally to the function is permitted but is a very bad thing to do.

vaj4088:
Returning an item from a function when that item was declared locally to the function is permitted but is a very bad thing to do.

Can you please show me proper way of doing it then ? I am really stuck with this atm

One way would be to use malloc(...) but I do not know if that works on an Arduino.
Another way would be to pass in the array (and the size of the array) as parameters.

Does that help, or do you need more?

(By the way, the usual advice is to NOT use String on an Arduino because it can lead to inefficient usage of memory. C strings (arrays of char ended with \0) are the recommended alternative.)

Can you please show me proper way of doing it then ?

pay attention

Double quotes, not single.

gcjr:
pay attention

Where have I used single quotes in the code I posted in the first post ?
if you are pointing to this ['ESP8266', 'network18', 'Jio'] then that is just an output I am wanting to have may it be
single or double output can be anyone, but in my code I have not used single quotes.

seaurchin:
How do get an array containg hotspot names like this :

 ['ESP8266', 'network18', 'Jio']

please help !

i should have said "you missed this" instead of "pay attention"

Colleagues at work have asked for help to find problems such as a ";" immediately after the closing parenthesis of an if. we don't see it because ... whatever.

Either make it global, and return the number you found, or make it static

this is sorted out thanks all.

It is standard operating procedure to do two things:

Modify the title to add [Solved].

Tell us what the solution was so that we can all learn.

Telling us the solution is not intended to embarrass you. We, even the experts, have made a lot of mistakes and have had to do a lot of learning.