Convert a hexadecimal string to an integer efficiently in C?

后端 未结 16 2224
暖寄归人
暖寄归人 2020-12-01 09:31

In C, what is the most efficient way to convert a string of hex digits into a binary unsigned int or unsigned long?

For example, if I have

16条回答
  •  没有蜡笔的小新
    2020-12-01 10:09

    #include "math.h"
    #include "stdio.h"
    ///////////////////////////////////////////////////////////////
    //  The bits arg represents the bit say:8,16,32...                                                                                                              
    /////////////////////////////////////////////////////////////
    volatile long Hex_To_Int(long Hex,char bits)
    {
        long Hex_2_Int;
        char byte;
        Hex_2_Int=0;
    
        for(byte=0;byte

提交回复
热议问题