2025-01-02 09:24 PM
Hello,
My question is about language Embedded C.
char data[100] = "300 0";
uint8_t* data_a = strtok(data, " "); // data_a printf result : "300"
// printf results data_a[0] : '3', data_a[1] : '0', data_a[2] : '0'
uint8_t* data_b = strtok(NULL, " "); // data_b printf result : "0"
uint8_t data_c = atoi(data_a); // data_c print result : 44 // Why??????????
uint8_t data_d = atoi(data_b); // data_d printf result : 0
When the input is the string "300", why is the output of the function "atoi" integer 44?
Any help is greatly appreciated!
Friendly regards, Tau
Solved! Go to Solution.
2025-01-02 09:51 PM
Oops, my mistake..!
# uint8_t datatype range : 0~255
uin8_t data_c = atoi("300"); // data_c printf result : 44 // Logical error : 300 > 255
2025-01-02 09:51 PM
Oops, my mistake..!
# uint8_t datatype range : 0~255
uin8_t data_c = atoi("300"); // data_c printf result : 44 // Logical error : 300 > 255