sizeof a string
hi all.
yet again question sizeof operator.
first example of code (without setup, loop etc.)
;
desired effect;
that first call prints
and second call prints
this get;
basically don't understand sizeof operator evaluating. strings not change while running program.
hoping explained problem enough,
jeroen
yet again question sizeof operator.
first example of code (without setup, loop etc.)
;
code: [select]
void function (char *_min, char *_max) (
byte = sizeof(_min);
byte b = sizeof(_max);
serial.println(a, dec);
serial.println(_min);
serial.println(b, dec);
serial.println(_max);
}
function ("0", "36"); // first call
function ("-10, "36"); // second calldesired effect;
that first call prints
code: [select]
1 (size of 0)
0
2 (size of 36)
36and second call prints
code: [select]
3
-10
2
36this get;
code: [select]
2 //first call
0
2
36
2 // second call
-10
2
36basically don't understand sizeof operator evaluating. strings not change while running program.
hoping explained problem enough,
jeroen
sizeof returns size in bytes of variable give it, not value associated variable. in c language, string variable pointer array of characters comprising string. arduino pointer 2 byes, sizeof correctly returns.
use strlen function length of string
use strlen function length of string
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > sizeof a string
arduino
Comments
Post a Comment