The following code works:
#include <ESP8266WiFi.h>
const char *ssid = "Your wifi Network name"; // replace with your wifi ssid and wpa2 key
const char *pass = "Network password";
WiFiClient client;
void setup()
{
Serial.begin(9600);
delay(10);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
}
But when the line:
const char *pass = "Network password";
is replaced with:
const char pass = "Network password";
The compiler throws an error.
Why does the character pointer (I think it is a pointer) make the code work, when it is never used elsewhere throughout the code?
I have had a look at the following link, but I am getting confused about the explanation:
error: invalid conversion from ‘const char*’ to ‘char’ [-fpermissive]