vagulus
1
I have a line of code
const byte masterAddress[5] = {"Boss "}; // or {'B','o','s','s',' '};
and the compiler returns
warning: initializer-string for array of chars is too long [-fpermissive]
Four charagcters and a space should equal five bytes by my primitive mathematice.
What is wrong here?
srnet
2
vagulus:
I have a line of code
const byte masterAddress[5] = {"Boss "}; // or {'B','o','s','s',' '};
and the compiler returns
warning: initializer-string for array of chars is too long [-fpermissive]
Four charagcters and a space should equal five bytes by my primitive mathematice.
What is wrong here?
But when you declare the sting it adds a null terminator;
https://www.arduino.cc/en/Reference/String
Robin2
4
srnet:
But when you declare the sting it adds a null terminator;
I think I would word that as "You need to leave an extra space for the null terminator that is added automatically"
I think the problem is your use of double quotes " which tell the compiler that you want to create a cstring with a terminator.
This should work
const byte masterAddress[5] = {'B','o','s','s',' '};
...R
system
5
This should work
As long as you don't ever try to use masterAddress as a string.
Robin2
6
PaulS:
As long as you don't ever try to use masterAddress as a string.
Indeed. I don't think it is intended to be used as a string.
...R