char msgPart1[11];
char msgPart2[11];
char msgPart3[11];
char msgPart4[11];
char tempLCD[21];
...
...
..
setup()
{
// Lcd init code goes here
lcd.clear();
strcat( tempLCD, msgPart1);
strcat( tempLCD, msgPart2);
lcd.print( tempLCD); // First Line of LCD prints fine...
lcd.setCursor(0, 1);
tempLCD[] = {""}; // Tried to clear the tempLCD but have not been able to ...
strcat( tempLCD, msgPart3);
strcat( tempLCD, msgPart4);
lcd.print( tempLCD); // If not cleared the first line content remains !!
As can be seen i am using the tempLCD[21] to print the concatenated char to each line and require to clear it before printing to the next line. ( I am using a 4 line x 20 Char LCD)
Goet:
When you print a char array, characters will be displayed one after another untill the null terminating character.
So, this should be sufficient:
I still think replacing the first strcat by strcpy is the better solution, it's smaller and faster.
Concatenating to a known empty string seems not very sensible to me.
And you can not forget any backslashes...
Wow ... that was super simple. Both methods suggested by Goet and Whandall work. Thanks folks. That was good learning.
Ok so now that the issue is cleared i am am working on a logic to exactly fit in the tempLCD[] to occupy 20 char width so that the display looks neatly filled.
Like for instance its not always that msgPart1 and msgPart2 are exactly 10 char width. They will be anything from 1 to 10. So the msgpart2 will need to start at the 11th position on the LCD ... i guess i just have to pad up the unused char positions in msgPart1 with required number of spaces.