Why is strcat one color(red)

and strlcat comes up as white?

It's not the colors themselves, cause mine may be different than yours just why different.

strlcat() is not a standard function. An attempt by the BSD's aficionados to “fix” strncat()

I'll be darned. Thanks.

better use strlcat() if you don't know the details and risks of strncat(). just make sure you pass in the right size

when you pass size do you add one for the null byte?

say what you will about String, it does keep you out of trouble from time to time.

if you use strlcat() you pass in the full size of the destination buffer and do not need to worry about the null termination.

strlcat(destBuffer, "stuff to add", sizeof destBuffer);

with strncat() the size if the max number of chars to add but can lead to a non null terminated cString in the destBuffer (or overflow)

1 Like

what if the stuff to add is less than dest, does it figure that out and add the null byte?

Hi @sevenoutpinball. Which version of the Arduino IDE are you using?

1.8.16

OK.

Arduino IDE 1.x uses RSyntaxTextArea for syntax highlighting.

In addition to highlighting the global, platform level, and library level custom keywords, RSyntaxTextArea also has a base list of keywords for each of its supported languages.

You can see that strcat is on that list:

but not strlcat (for the reason already explained).

Arduino IDE 2.x does not use RSyntaxTextArea, so this information is specific to Arduino IDE 1.x (thus why the topic was moved out of the "Arduino IDE 2.0 beta" forum category)

oh, ok. I'm so dumb I didn't even realize they break out the forums for each IDE type etc. But thanks for the explanation!!

You're welcome.

Arduino IDE 2.x is a complete rewrite of the Arduino IDE, which shares only some of the low level non-GUI tooling with the 1.x version. So at this point quite a bit of the questions and discussions about one IDE don't apply to the other.

For example, this is how the keywords discussed here look in Arduino IDE 2.x:

12 posts were split to a new topic: Is it hard to switchover from 1.x to 2.x?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.