C++: Converting Hexadecimal to Decimal

前端 未结 7 1698
一向
一向 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:12
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    
    int main()
    {
        int x, y;
        std::stringstream stream;
    
        std::cin >> x;
        stream << x;
        stream >> std::hex >> y;
        std::cout << y;
    
        return 0;
    }
    
    0 讨论(0)
提交回复
热议问题