CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: char to hex

  1. #1
    Join Date
    Nov 2001
    Location
    MD
    Posts
    13

    char to hex

    I have a char string called buf[2]. buf[0] and buf[1] are not characters, but hexadecimal numbers that I need to extract. Lets say, buf[0] = 0x02 and buf[1] = 0x70. How can I put these two numbers together (to form the hex number 0x0270) to form an int value?? Thanks.

  2. #2
    Join Date
    Jul 2001
    Location
    Otaki, New Zealand
    Posts
    303
    Try

    int lResult = (Buf[0] << 8) + Buf[1];

    Regards
    Alan

  3. #3
    Join Date
    Nov 2001
    Location
    MD
    Posts
    13
    It Worked!! Thanx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured