Go Down

Topic: String concatenation and printing (Read 13 times) previous topic - next topic

samtal

Hi,
I have 2 strings in a mixed struct.
The strings are defined in the struct as char string
  • , and given string values.

To print out, I concatenate several strings into one longer string, and print it out via serial print command.
So far, so good.
Problem is that while it printed correctly in previous versions of my code, it does not print in a new version, with very little change from previous.
Unfortunately, I could not figure out what made the change.

Here is my code snippet:

#include <string.h>
.
.

struct defineConfigs {   
  .
  char configVersion[4];
  char versionDate[11];   
. (more items in the struct)
.
.
}
configData = {
 .
  "B60",
  "22-05-15",
.(more items)
.
}

The print command in the setup():

Serial.println((String)"Rev " + configData.configVersion + " " + configData.versionDate);

While in the previous version it printed out the strings as they appear, namely "Rev B60 22-05-15"
in the new version it always prints out "Rev 32".

I send the same string to the lcd, and get the same outcome.

There seem to be no relevant difference between the versions, and yet it will always print "Rev 32"
(32 is the ascii code for space(?))

What i the correct way to define and concatenate the strings and make them always print correctly?

Thanks

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy