#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    lincoln
    Posts
    7
    Rep Power
    0

    Need Help with Hexadecimal in C.


    Hi All,
    Can any one tell me how I can pad a string with hexadecimal values in C. I am new to this area. A string str1 should look like this:
    [hexadecimal 2]str1[hexadecimal 3]. This is done just to make sure that str1 can contain any value and when i am reading it i will know that it starts with hexadecimal 4 and ends with hexadecimal 3.

    Thanks,
    Mani.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    55
    Rep Power
    12
    "\x02bleh\x03"
    But your method of making sure it can contain any value does not work, what if they want a 3 in there of their own?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    lincoln
    Posts
    7
    Rep Power
    0
    Hi xtor,
    I am not able to get this work....I would appriciate if u can give sample stmts of how to convert say "int i".

    Thanks,
    Abid.
    Originally posted by xtor
    "\x02bleh\x03"
    But your method of making sure it can contain any value does not work, what if they want a 3 in there of their own?
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    Originally posted by mani
    Hi xtor,
    I am not able to get this work....I would appriciate if u can give sample stmts of how to convert say "int i".

    Thanks,
    Abid.
    How to convert it to what? Please be more specific about what you want. Are you wanting to embed arbitrary byte-values into your string using hexadecimal notation (which xtor showed you how to do)? Do you want to embed the value of a byte variable (unsigned char) into a string? Do you want to insert the ASCII representation of a hex value into a string? What is it that you want?

IMN logo majestic logo threadwatch logo seochat tools logo