You certainly can not assign WLAN_SSID
to a char*
because string literals are of type char const[N]
(with a suitable N
) which happily decay into char const*
s but refuse to be assigned to char*
s. If you really need to deal with a char*
, you'll need to allocate sufficient space and copy the value into this memory. Of course, when changing it you'll also need to release the memory appropriately. For example
char* make_ssid(char const* value) {
static std::unique_ptr<char[]> memory;
std::size_t n = strlen(value);
memory.reset(new char[n + 1]);
strncpy(memory.get(), value, n + 1);
return memory.get();
}
char* ssid = make_ssid(WLAN_SSID);