Convert a hexadecimal string to an integer efficiently in C?

后端 未结 16 2209
暖寄归人
暖寄归人 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:06

    Why is a code solution that works getting voted down? Sure, it's ugly ...

    Perhaps because as well as being ugly it isn't educational and doesn't work. Also, I suspect that like me, most people don't have the power to edit at present (and judging by the rank needed - never will).

    The use of an array can be good for efficiency, but that's not mentioned in this code. It also takes no account of upper and lower case so it does not work for the example supplied in the question. FFFFFFFE

提交回复
热议问题