Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. want to take hex dump of a string. How ?

want to take hex dump of a string. How ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++jsonquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sakthiu
    wrote on last edited by
    #1

    Hi, I want to take hex dump of a string and print like "00.ff.2e:3f:00:4d". Is there any api available in 'C' or 'C++' ? Thanks, Sakthi

    Nice things do nice works

    C enhzflepE 2 Replies Last reply
    0
    • S Sakthiu

      Hi, I want to take hex dump of a string and print like "00.ff.2e:3f:00:4d". Is there any api available in 'C' or 'C++' ? Thanks, Sakthi

      Nice things do nice works

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Well, there are keywords & functions, for instance: strlen, for, printf. :rolleyes: :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      1 Reply Last reply
      0
      • S Sakthiu

        Hi, I want to take hex dump of a string and print like "00.ff.2e:3f:00:4d". Is there any api available in 'C' or 'C++' ? Thanks, Sakthi

        Nice things do nice works

        enhzflepE Offline
        enhzflepE Offline
        enhzflep
        wrote on last edited by
        #3

        Code: printf("%02d:%02d:%02d:%02d:%02d:%02d\n", 0x00, 0xff, 0x2e, 0x3f, 0x00, 0x4d); printf("%02x:%02x:%02x:%02x:%02x:%02x\n", 0x00, 0xff, 0x2e, 0x3f, 0x00, 0x4d); Output: 00:255:46:63:00:77 00:ff:2e:3f:00:4d

        S 1 Reply Last reply
        0
        • enhzflepE enhzflep

          Code: printf("%02d:%02d:%02d:%02d:%02d:%02d\n", 0x00, 0xff, 0x2e, 0x3f, 0x00, 0x4d); printf("%02x:%02x:%02x:%02x:%02x:%02x\n", 0x00, 0xff, 0x2e, 0x3f, 0x00, 0x4d); Output: 00:255:46:63:00:77 00:ff:2e:3f:00:4d

          S Offline
          S Offline
          Sakthiu
          wrote on last edited by
          #4

          for me, why happens like this below, ffffffde:0e:6e:28:53:3d:ffffff88:0d:ffffff87:ffffffc1:ffffffe7: 4f:ffffffe8:ffffff9d:ffffff84:ffffffe8:3d:06:ffffff81:ffffffe0: ffffff8f:ffffff9a:77:08:75:3d:fffffff1:38:45:ffffff8f:ffffffe8: ffffffad:03 Thanks, Sakthi

          Nice things do nice works

          C 1 Reply Last reply
          0
          • S Sakthiu

            for me, why happens like this below, ffffffde:0e:6e:28:53:3d:ffffff88:0d:ffffff87:ffffffc1:ffffffe7: 4f:ffffffe8:ffffff9d:ffffff84:ffffffe8:3d:06:ffffff81:ffffffe0: ffffff8f:ffffff9a:77:08:75:3d:fffffff1:38:45:ffffff8f:ffffffe8: ffffffad:03 Thanks, Sakthi

            Nice things do nice works

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #5

            Hint: you're probably using signed data types. :rolleyes: Hint2: FFFFFFDE is -34 (i.e. 222 if _unsigned_ char). :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups