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. char[n] to int ?

char[n] to int ?

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++iostutorialquestion
6 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Im helping out someone with this problem and im stuck, it been sometime since i used c++. He reads in a file (ios::binary) and char version [30]; // ... file.get(version, 30); Now the in version[0] is a char value, i want the decimal value, for example, 0x18 is "cancle" (looks like a up arrow in text). I want the decimal value 24 from 0x18, or take the char "cancle" and get 24. the reason i need the decimal value is because it represents the lenght of the data string after version[0]. 30 is the max the string can be so thats why i need the decimal value of version[0]. Its just to tell the user what version the file being read is. Can anyone help me on this? Thanks.

    J H 2 Replies Last reply
    0
    • L Lost User

      Im helping out someone with this problem and im stuck, it been sometime since i used c++. He reads in a file (ios::binary) and char version [30]; // ... file.get(version, 30); Now the in version[0] is a char value, i want the decimal value, for example, 0x18 is "cancle" (looks like a up arrow in text). I want the decimal value 24 from 0x18, or take the char "cancle" and get 24. the reason i need the decimal value is because it represents the lenght of the data string after version[0]. 30 is the max the string can be so thats why i need the decimal value of version[0]. Its just to tell the user what version the file being read is. Can anyone help me on this? Thanks.

      J Offline
      J Offline
      John Saunders
      wrote on last edited by
      #2

      int length = (int)version[0]; cout << "value should be 24 <" << length << ">" << endl;

      L 1 Reply Last reply
      0
      • J John Saunders

        int length = (int)version[0]; cout << "value should be 24 <" << length << ">" << endl;

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

        Thanks. I swear i though i tried that but had an error and wrote if off. :) edit: Well it wasnt an error but a '0'. When i run it through VS2005 i get a zero, but when i go to the .exe and double click it i get 24. Thats why i wrote it off i dont get the right values when running through VS2005. IT was driving me nuts out of the blue i double click the .exe and bam it works. dang VS2005 -- modified at 1:50 Monday 31st July, 2006

        1 Reply Last reply
        0
        • L Lost User

          Im helping out someone with this problem and im stuck, it been sometime since i used c++. He reads in a file (ios::binary) and char version [30]; // ... file.get(version, 30); Now the in version[0] is a char value, i want the decimal value, for example, 0x18 is "cancle" (looks like a up arrow in text). I want the decimal value 24 from 0x18, or take the char "cancle" and get 24. the reason i need the decimal value is because it represents the lenght of the data string after version[0]. 30 is the max the string can be so thats why i need the decimal value of version[0]. Its just to tell the user what version the file being read is. Can anyone help me on this? Thanks.

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          See Here[^] maybe it is some helpful to you

          _**


          **_

          WhiteSky


          T 1 Reply Last reply
          0
          • H Hamid Taebi

            See Here[^] maybe it is some helpful to you

            _**


            **_

            WhiteSky


            T Offline
            T Offline
            toxcct
            wrote on last edited by
            #5

            codeguru again ??!! :((


            TOXCCT >>> GEII power

            [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

            H 1 Reply Last reply
            0
            • T toxcct

              codeguru again ??!! :((


              TOXCCT >>> GEII power

              [VisualCalc 3.0  updated ][Flags Beginner's Guide  new! ]

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Hello Mr toxcct, How are you?did you have a good weekends? I can say only ::-O and i say again, Viens,laissons l'Avenir;laissons nos chagrins fous. Jouissons du present et si doux!(Khayyam)

              _**


              **_

              WhiteSky


              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