You have to post the complete program for an answer.
However, I guess the const char* type definition is appropriate only if the credentials are embedded in the program and, therefore, known at compile time.
I also have the same problem with my ESP8266 board no matter the different types of code I do. Sometimes however, it does work so I am not to sure of a fix hardware or software wise
Shows us the program and we can have a look, rarely it will be a hardware issue, If the credentials are in a char array (buffer) it is not required for them to be known at compile time.