Copying an array of bytes to a String

Hello Mateo,

First, this is part of your other conversation “Converting custom Data Structure to String - Ask Questions - B&R Community (br-automation.com).” Please keep the conversation in a single thread.

Second, your string will look empty if the first byte of data is 0 or NULL. A null (denoted as \0, 0 value, not the character) is an indicator that the end of the string is reached, and no further characters should be displayed.

‘Hello’ as a string looks like: ‘H’ ‘e’ ‘l’ ‘l’ ‘o’ \0 in memory
If you move the \0 to the front, making it: \0 ‘H’ ‘e’ ‘l’ ‘l’ ‘o’ in memory, then the resulting string is blank/empty.

Additional reading on STRINGS:

-Austin

2 Likes