My thinking is that, when I'm reading code, it's a lot easier for me to read apple, box etc and know what they mean, but if there's no inherrant relationship between them, it seems that it shouldn't matter if they're stored as values that do.
(I realise there have been similar posts about this, but I've not seen one that I can see quite addresses the question. And I don't have a specific use yet.)
(And sorry if it's a stupid question.)
Neither of the above contain an array of characters.
// int apple, banana, carnage, delicious;
// int something[4] = { apple, banana, carnage, delicious }; // four x 16 bits
// char apple, banana, carnage, delicious;
// char something[4] = {apple, banana, carnage, delicious}; // four x 8 bits
char something[][9] = {"apple\0", "banana\0", "carnage\0", "delicious\0"}; // four x 8 x (numchars + 1)
void setup() {
Serial.begin(115200);
for (int i = 0; i < 4; i++)
Serial.println(something[i]);
}
void loop() {}
with array of ints
Sketch uses 1766 bytes (5%) of program storage space. Maximum is 30720 bytes.
Global variables use 196 bytes (9%) of dynamic memory, leaving 1852 bytes for local variables. Maximum is 2048 bytes.
With array of chars
Sketch uses 1492 bytes (4%) of program storage space. Maximum is 30720 bytes.
Global variables use 192 bytes (9%) of dynamic memory, leaving 1856 bytes for local variables. Maximum is 2048 bytes.
With array of characters:
Sketch uses 1534 bytes (4%) of program storage space. Maximum is 30720 bytes.
Global variables use 224 bytes (10%) of dynamic memory, leaving 1824 bytes for local variables. Maximum is 2048 bytes.