C++: Converting Hexadecimal to Decimal

前端 未结 7 1740
一向
一向 2020-11-30 11:49

I\'m looking for a way to convert hex(hexadecimal) to dec(decimal) easily. I found an easy way to do this like :



        
7条回答
  •  自闭症患者
    2020-11-30 12:10

    Use std::hex manipulator:

    #include 
    #include 
    
    int main()
    {
        int x;
        std::cin >> std::hex >> x;
        std::cout << x << std::endl;
    
        return 0;
    }
    

提交回复
热议问题