C++: How to output a Char value as a Hex value?

Discussion in 'OT Technology' started by AbortionSurvivor, Jun 25, 2003.

  1. AbortionSurvivor

    AbortionSurvivor Active Member

    Joined:
    Jun 5, 2002
    Messages:
    3,016
    Likes Received:
    0
    Location:
    Nor. Cal
    If i am given a Char value, how can i output this value as a Hex?

    Ex. if i am given the Character 'K'. How can i output '4A' (Hex)

    are there pre-defind functions in the library?
     
  2. BaZ

    BaZ 2004 ACC Champions

    Joined:
    Jun 12, 2001
    Messages:
    2,005
    Likes Received:
    0
    Location:
    Hokieville, USA
    i don't know of any other way to do it but to typecast it to some sort of integer and have a lookup table of some sort
     
  3. skinjob

    skinjob Active Member

    Joined:
    Jan 6, 2001
    Messages:
    2,337
    Likes Received:
    0
    Location:
    Aztlán
    printf("%2.2X", (unsigned int)c);
     

Share This Page