2byte Hex String to int!


/ Published in: C++
Save to your folder(s)

Hex2Int("FF")
returns 255
(if anyone has a better way todo this PLEASE let me know ;) )


Copy this code and paste it in your HTML
  1. int Hex2Int(char i[])
  2. {
  3. int d=0;
  4. int a =0;
  5. char out[10];
  6. sscanf(i, "%02x", &a);
  7. sprintf(out, "%d",a);
  8. stringstream(out) >> d ;
  9. return d;
  10. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.