I am struggling to understand what's happening when I use strcat to join two variables, which results in the desired char array plus the undesirable change to a different char array.
I've reduced the problem to the code example below. Normally, the #define is in another file for security purposes.
char wxServer[] = "blah.com";
char wxAPI[] = "/dowxstuff/now?";
#define ID "Login"
void setup() {
Serial.begin(115200);
}
void loop() {
delay(1000);
Serial.println(wxServer);
Serial.println(wxAPI);
Serial.println(ID);
strcat(wxAPI, ID);
Serial.println(wxAPI);
Serial.println(wxServer);
Serial.println(ID);
delay(999999999);
}
This results in the following:
12:54:55.783 -> blah.com
12:54:55.783 -> /dowxstuff/now?
12:54:55.783 -> Login
12:54:55.783 -> /dowxstuff/now?Login
12:54:55.783 -> ogin <====== what happened to blah.com, and what ate the letter L?
12:54:55.783 -> Login
I still have my C++ training wheels so I assume I'm just making a bonehead mistake here.