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

Thread: Hex conversion

  1. #1
    Join Date
    Apr 1999
    Posts
    4

    Hex conversion

    I need to convert string "A1A2A3A4" to "\xA1\xA2\xA3\xA4"
    and "\xA1\xA2\xA3\xA4" to "A1A2A3A4".

    I can do this by splitting string "A1A2A3A4" on "A1" "A2" "A3" "A4"
    and then passing to strtol("0xA1", &stopstring, 16);
    The result added to string. Is it possible to do this using sscanf and sprintf.


    Thank you for any better idea.


    Maria F. Kornievskaya

  2. #2
    Join Date
    May 1999
    Posts
    92

    Re: Hex conversion

    What exactly do you mean by "\xA1 ....."
    Are you trying to convert from one base to another?


  3. #3
    Join Date
    Apr 1999
    Posts
    4

    Re: Hex conversion

    Yes. I've done this. But I believe that there is a simplier decision with sscanf and sprintf functions using.

    Have you used them for this purpose?

    Maria F. Kornievskaya

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