convert hex to int (sprintf?)
(I am using borland builder 6)
I have a std::string , of variable length, that contains hex. The hex is guaranteed to be the equivilent of numbers, not characters (its source is a field in a packet).
How would I convert this hex string to an int ? I was thinking sprintf, but i dont see how.
Please post an examlpe function if possible.
Thank you
Brian
[384 byte] By [
BrianB] at [2007-11-18 22:22:33]

# 2 Re: convert hex to int (sprintf?)
Thank you, can you give an example of converting hex to int?
# 3 Re: convert hex to int (sprintf?)
Here's an example in C++.
#include <string>
#include <sstream>
#include <ios>
using namespace std;
int main()
{
string str("1A A1");
stringstream in(str);
int value1, value2;
in >> hex >> value1 >> value2;
return 0;
}
Kheun at 2007-11-9 0:36:58 >
