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. Hexidecimal to decimal conversion

Hexidecimal to decimal conversion

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 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.
  • P Offline
    P Offline
    PaulJ
    wrote on last edited by
    #1

    Hi, Has anyone out there have a routine that converts a Hexidecmal String to a DWORD? Paul Jahans

    R N R 3 Replies Last reply
    0
    • P PaulJ

      Hi, Has anyone out there have a routine that converts a Hexidecmal String to a DWORD? Paul Jahans

      R Offline
      R Offline
      Rick York
      wrote on last edited by
      #2

      Try stroul. You can specify a base parameter of 16 or if the strings will have "0x" at the beginning then you can use a base of 0 and the function will sort it out. If you prefer, it is a fairly simple matter to write your own.

      1 Reply Last reply
      0
      • P PaulJ

        Hi, Has anyone out there have a routine that converts a Hexidecmal String to a DWORD? Paul Jahans

        N Offline
        N Offline
        Niklas L
        wrote on last edited by
        #3

        unsigned long strtoul( const char *nptr, char **endptr, int base

        1 Reply Last reply
        0
        • P PaulJ

          Hi, Has anyone out there have a routine that converts a Hexidecmal String to a DWORD? Paul Jahans

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Here's one way to do it. You should add error checking.

          DWORD hexStringToDword
          (char* szHexString)
          {
          DWORD dwValue = 0;
          sscanf (szHexString, "%X", &dwValue);
          return (dwValue);
          }

          /ravi "There is always one more bug..." http://www.ravib.com ravib@ravib.com

          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