convert HEX string to Decimal in arduino

后端 未结 2 439
傲寒
傲寒 2020-12-21 12:34

i have an Hex String like this : \"0005607947\" and want to convert it to Decimal number , i test it on this site and it correctly convert to decimal number and answer is :

2条回答
  •  天涯浪人
    2020-12-21 12:43

    Drop all that code, and just use 'strtol' from the standard library.

     #include 
     long strtol (const char *__nptr, char **__endptr, int __base)
    

    For your use:

    long decimal_answer = strtol("0005607947", NULL, 16);
    

提交回复
热议问题