Go Down

Topic: String or Char Arrays Length Definition (Read 2 times) previous topic - next topic

PaulS

Quote
But I don't know how to work around strlen()

I don't understand why you think you need to. That example won't work, for several reasons.

First, Serial.read() returns ONE character, not a string.

Second, there is no variable defined called $tmpName, which is not a valid name in C++.

Third, you can't assign an array (if that is what the undefined tmpName is supposed to be) to another array that way.

tavovalencia

OK, I get It... I was trying to do the 3rd.

I wanted to add a string or an array of characters after user inputs the text and hits "send"

PaulS

Quote
I wanted to add a string or an array of characters after user inputs the text and hits "send"

strcat() does that.

tavovalencia

OK, but how can I limit strcat() to 8 chars?

pYro_65

You could overload the function to add in another parameter, or put a null in the source at the position you want it to stop copying at.
If needed, store the 8th character in a temp, replace with null, when done just put the temp char back.

Go Up