search
[last updated: 2026-06-08]
Arduino programming
-----
On this page:
==============================================
-----------------------------------------------------
-----------------------------------------------------
if you define your array with: ary1[10];
then sizeof(ary1) returns 10 (the memory reserved for it as you've defined it)
and unless you've put something into it after defining it,
strlen(ary1) will be indeterminate
further, Serial.print(ary1); will also be indeterminate
if you define the array with: ary2[] = "asdf";
then sizeof(ary2) returns 5, the total memory space reserved for it, which is the actual number of chars in it, plus the null termination
also, strlen(ary2) returns 4, the actual number of chars in it
and Serial.print(ary2) will return "asdf"
if the array was created with eg. ary3[10] = "asdf";
then sizeof(ary3) will return 10,
strlen(ary3) will return 4,
if you define the array as: ary4[10];
then sizeof(ary4) will always return 10 as noted above,
and as noted, if you haven't otherwise added elements to it, then strlen(ary4) will be indeterminate,
but then if you manually add elements to it, with eg.:
ary4[0] = 'a';
ary4[1] = 's';
then strlen(ary4) will STILL be indeterminate,
unless you remember to manually add a null termination, eg:
ary4[2] = '\0';
in which case strlen(ary4) will return 2 (the 'a' and 's' that you manually added)
However I could not get this to work on my current IDE 2.3.6.
Cmp value changed each time through loop even though parameters didn't...
.
.
.
eof