Hi
I have the following string :
"1F"
I need to present it as a BYTE
so if I have : BYTE array[2]
then -> array[0] = 0x1F
How can it be done?
Thank u
Printable View
Hi
I have the following string :
"1F"
I need to present it as a BYTE
so if I have : BYTE array[2]
then -> array[0] = 0x1F
How can it be done?
Thank u
Code:#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
const char* hexNum = "1F";
int actualByte = 0;
// one method
istringstream is(hexNum);
is >> hex >> actualByte;
cout << hex << actualByte << endl;
// another method
sscanf(hexNum, "%02x", &actualByte);
cout << hex << actualByte << endl;
return (0);
}