ltoa — convert the integer type into string.
Description:
u8 ltoa(u8 *string, u8 value);
Convert the integer number value into string string and returns the string length of string.
List of parameters
string
Pointer to the string into which the number is converted.
value
Convertable number.
Return values:
Function returns the string length of string after converting into it the number value.
Example:
<item addr="524:248" name="Test for ltoa function" type="script"> V-ID/V-ADDR { if(opt0()) { u16 int_1 = 1233; u8 int_2 = 0xCF; u8 str_1[10]; u8 str_2[10]; u8 str_3[10]; u8 str_4[10]; // Example: 1 u8 len_1 = ltoa(&str_1, int_1); // Example: 2 u8 len_2 = ltoa(&str_2, int_2); // Example: 3 u8 len_3 = ltoa(&str_3, 37); // Example: 4 u8 len_4 = ltoa(&str_4, 0xFFFF); //output u8 strForMess[70]; sprintf(strForMess, "%cstr_1 - %s\10str_2 - %s\10str_3 - %s\10str_4 - %s\10", 1, str_1, str_2, str_3, str_4); setStatus(@exciterId():32, &strForMess); sprintf(strForMess, "%clen_1 - %d\10len_2 - %d\10len_3 - %d\10len_4 - %d\10", 4, len_1, len_2, len_3, len_4); setStatus(@exciterId():32, &strForMess); } }
The result of performing the example in the interface:
str_1: 1233
str_2: 207
str_3: 37
str_4: 65
len_1: 4
len_2: 3
len_3: 2
len_4: 5