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. Is there any function that can convert text representation"ABCDEF" back to int ?

Is there any function that can convert text representation"ABCDEF" back to int ?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 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.
  • C Offline
    C Offline
    Cold_Fearing_Bird
    wrote on last edited by
    #1

    _itoa can convert int value such as 15 to F, but the atoi function cannot convert it back. it simply treat any letter that is not numerical( '0' - '9' ) as wrong input value. I have an edit control to display something hexadecimal, say a pointer, a handle,so I do the follow, _itoa( i, szBuffer, 16 ) ; SetDlgItemText( hDlg,szBuffer ) ; when I want the value back, I need to convert it back to int representation. But I am stuck here. Does someone know any function that fix my problem?

    L J 2 Replies Last reply
    0
    • C Cold_Fearing_Bird

      _itoa can convert int value such as 15 to F, but the atoi function cannot convert it back. it simply treat any letter that is not numerical( '0' - '9' ) as wrong input value. I have an edit control to display something hexadecimal, say a pointer, a handle,so I do the follow, _itoa( i, szBuffer, 16 ) ; SetDlgItemText( hDlg,szBuffer ) ; when I want the value back, I need to convert it back to int representation. But I am stuck here. Does someone know any function that fix my problem?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Try one of these functions[^], which allow you to specify the number base.

      Unrequited desire is character building. OriginalGriff

      1 Reply Last reply
      0
      • C Cold_Fearing_Bird

        _itoa can convert int value such as 15 to F, but the atoi function cannot convert it back. it simply treat any letter that is not numerical( '0' - '9' ) as wrong input value. I have an edit control to display something hexadecimal, say a pointer, a handle,so I do the follow, _itoa( i, szBuffer, 16 ) ; SetDlgItemText( hDlg,szBuffer ) ; when I want the value back, I need to convert it back to int representation. But I am stuck here. Does someone know any function that fix my problem?

        J Offline
        J Offline
        JohnNawrocki
        wrote on last edited by
        #3

        I assume you are talking about converting character hexadecimal representation to an integer. Look at: http://www.dreamincode.net/code/snippet805.htm[^]

        John Nawrocki Chief Technical Advisor Custom Molded Products

        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