首页 > 代码库 > Hex string convert to integer with stringstream

Hex string convert to integer with stringstream

#include <sstream>
#include <iostream>
int main() {
unsigned int x;
std::stringstream ss;
ss << std::hex << "FF";
ss >> x;
// output it as a signed type
std::cout << static_cast<int>(x) << std::endl;
}

Hex string convert to integer with stringstream