The code below prints two lines - the first time numerals and the second time Alphabets.
But if I comment out the line where i clear the array lcdMsgToPrint[] , it does not even print the numerals. Instead it prints some odd characters. Why is that ?
Just after brief look, the lcdMsgToPrint is not initialized so it may contain random characters. The strcat() appends the string at position of the first zero char occurance. It can be anywhere, even the behind the end of variable with regard to its length. Try to put
lcdMsgToPrint[0] = 0;
somewhere at the begining of setup. Or declare it initialized with zeros.
Oh yes... you are right. When I did not have that line to flush the lcdMsgToPost [] variable, I was actually trying to copy the 11 Alphabets to the existing Numerals ! And I was expecting that strcpy() will overwrite the existing ... no it copies the new values to the end of the existing ones.
Naturally lcdMsgToPost ran out of space and ended up crashing the MCU.
I tried the same code but with lcdMsgToPost set to 25 elements and found that now the Alphabets were added to the numerals !