C++ convert hex string to signed integer
问题 I want to convert a hex string to a 32 bit signed integer in C++. So, for example, I have the hex string \"fffefffe\". The binary representation of this is 11111111111111101111111111111110. The signed integer representation of this is: -65538. How do I do this conversion in C++? This also needs to work for non-negative numbers. For example, the hex string \"0000000A\", which is 00000000000000000000000000001010 in binary, and 10 in decimal. 回答1: use std::stringstream unsigned int x; std: