Convert a hexadecimal string to an integer efficiently in C?

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

    Hexadecimal to decimal. Don't run it on online compilers, because it won't work.

    #include
    void main()
    {
        unsigned int i;
        scanf("%x",&i);
        printf("%d",i);
    }
    

提交回复
热议问题