Thread: Convet Characters into HEX

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Convet Characters into HEX

    Hello,

    I currently have a character array of 16 chars. These 16 chars are actually HEX pairs meaning hexstring[0] = 3 hexstring[1] = f, hexstring[2]=3 hexstring[3]=d, ectc. What I need to do is join these HEX pairs togather and create an array of 8 chars.

    I need to be able to take hexstring[0] and hexstring[1] and turn them into the HEX(3f from above) and make 3f = to newString[0].

    Thanks for your help,

    techyjt

  2. #2
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    Run a loop 8 times, each time picking up 2 chars and use strtol() to convert it to an integer. In a new variable declared as 8 bytes, store this converted number at a specific location ranging from 0 to 7 being incremented each time the above loop increments.

  3. #3
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You'll find something similar if you look hard enough.....
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  4. #4
    Registered User
    Join Date
    Jul 2002
    Posts
    2
    Thanks. I did a search, just couldn't find much. Sorry.

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by techyjt
    Thanks. I did a search, just couldn't find much. Sorry.
    OK, but you did look at this one. It doesn't answer your question directly, but it gives you some clues.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 11
    Last Post: 06-16-2011, 11:59 AM
  2. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  3. displaying hex characters
    By pastitprogram in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 02:18 PM
  4. Replies: 11
    Last Post: 03-24-2006, 11:26 AM
  5. How do I increment printf hex characters?
    By gechno in forum C Programming
    Replies: 2
    Last Post: 05-24-2004, 05:33 PM