sizeof a string


hi all.

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 call


desired effect;
that first call prints
code: [select]

1  (size of 0)
0  
2  (size of 36)
36

and second call prints
code: [select]

3  
-10
2
36


this get;
code: [select]
2     //first call
0
2
36
2     // second call
-10
2
36


basically 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


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > sizeof a string


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums