Page 1 of 1

atoi

Posted: 05 Mar 2017 00:25
by 10der
hello!

how to convert char* to int
standard c++ atoi function is not supported by z-uno core.

thanks!

Re: atoi

Posted: 05 Mar 2017 11:25
by 10der
(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;
}


Re: atoi

Posted: 05 Mar 2017 13:54
by PoltoS
We will add atoi in 2.0.9. It should already be in strings.h, but probably the prototype is not declared in headers. We will take care

Re: atoi

Posted: 15 Mar 2017 15:43
by PoltoS

Re: atoi

Posted: 19 Sep 2017 16:17
by milimilo
Hello,

It seems that atoi/atol/atof are still not supported even in 2.1
I still have an error message.

Re: atoi

Posted: 24 Sep 2017 00:51
by PoltoS
It was tested to work. Lease send us more info to reproduce it