hello!
how to convert char* to int
standard c++ atoi function is not supported by z-uno core.
thanks!
atoi
Re: atoi
(facepalm)
Code: Select all
int toInt(char* str) {
int s = 1;
int i = -1;
int res = 0;
if (str[0] == '-') {
s = -1;
i = 0;
}
while (str[++i] != '\0') { //iterate until the array end
res = res * 10 + (str[i] - '0'); //generating the integer according to read parsed numbers.
}
res = res * s;
#ifdef DEBUG
Serial.println(res);
#endif
return res;
}