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. CSting ASCII to decimal Number

CSting ASCII to decimal Number

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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.
  • A Offline
    A Offline
    azhari24
    wrote on last edited by
    #1

    how to convert an CString ASCII to decimal number? For example, an "A" alphabet in ASCII table is 65 in decimal number, how can i convert the alphabet to an integer as 65. I get data from serial port MSCOMM VARIANT in_dat; in_dat = m_comm.GetInput(); CString strInput(in_dat.bstrVal); I want conver strInput alphabet to decimal. i'm sorry, I can't speak english fluently. thx

    _ L 2 Replies Last reply
    0
    • A azhari24

      how to convert an CString ASCII to decimal number? For example, an "A" alphabet in ASCII table is 65 in decimal number, how can i convert the alphabet to an integer as 65. I get data from serial port MSCOMM VARIANT in_dat; in_dat = m_comm.GetInput(); CString strInput(in_dat.bstrVal); I want conver strInput alphabet to decimal. i'm sorry, I can't speak english fluently. thx

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      atoi,atof should help you You can also use variant type changing functions Convert string to double:CComVariant myVar; double result; // myVar has some double value in string format say 123.345 if(myVar.ChangeType(VT_R8)==S_OK) result=myVar.dblVal;
      You should read this[^] link to understand how this can be done in more than one way.

      You talk about Being HUMAN. I have it in my name AnsHUMAN

      modified on Tuesday, July 19, 2011 12:26 AM

      1 Reply Last reply
      0
      • A azhari24

        how to convert an CString ASCII to decimal number? For example, an "A" alphabet in ASCII table is 65 in decimal number, how can i convert the alphabet to an integer as 65. I get data from serial port MSCOMM VARIANT in_dat; in_dat = m_comm.GetInput(); CString strInput(in_dat.bstrVal); I want conver strInput alphabet to decimal. i'm sorry, I can't speak english fluently. thx

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

        Assuming you are reading each byte one at a time, then the values are already integers. A byte containing the character 'A' is the same as the value 65 decimal. There is no conversion necessary, just accept the data as integer, not string.

        The best things in life are not things.

        A 1 Reply Last reply
        0
        • L Lost User

          Assuming you are reading each byte one at a time, then the values are already integers. A byte containing the character 'A' is the same as the value 65 decimal. There is no conversion necessary, just accept the data as integer, not string.

          The best things in life are not things.

          A Offline
          A Offline
          azhari24
          wrote on last edited by
          #4

          okey. Thanks for your help.

          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