Convert hex string (char []) to int?

前端 未结 13 1201
栀梦
栀梦 2020-11-22 12:12

I have a char[] that contains a value such as \"0x1800785\" but the function I want to give the value to requires an int, how can I convert this to an int? I have searched a

13条回答
  •  天命终不由人
    2020-11-22 12:51

    I made a librairy to make Hexadecimal / Decimal conversion without the use of stdio.h. Very simple to use :

    unsigned hexdec (const char *hex, const int s_hex);
    

    Before the first conversion intialize the array used for conversion with :

    void init_hexdec ();
    

    Here the link on github : https://github.com/kevmuret/libhex/

提交回复
热议问题