Posted By

mouseroot on 10/17/10


Tagged


Versions (?)

2byte Hex String to int!


 / Published in: C++
 

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

  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  

You need to login to post a comment.