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. casting CString to int

casting CString to int

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

    I have a CString of 6 numbers how can i cast into one int variable so i can compare it with different numbers. /\|-||\/|/\|)

    T M S 3 Replies Last reply
    0
    • H Halawlaws

      I have a CString of 6 numbers how can i cast into one int variable so i can compare it with different numbers. /\|-||\/|/\|)

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

      int i;
      CString str = "32";
      sscanf(str, "%d", &i);
      ASSERT(i == 32);


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      H 1 Reply Last reply
      0
      • T toxcct

        int i;
        CString str = "32";
        sscanf(str, "%d", &i);
        ASSERT(i == 32);


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        H Offline
        H Offline
        Halawlaws
        wrote on last edited by
        #3

        One more thing... can i do this without the Assert coz i don't know the value of str in my program thx anyway /\|-||\/|/\|)

        T 1 Reply Last reply
        0
        • H Halawlaws

          One more thing... can i do this without the Assert coz i don't know the value of str in my program thx anyway /\|-||\/|/\|)

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

          certainly, ASSERT() was just here to show you that aftrer treatment, the int contains the string's value...


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          H 1 Reply Last reply
          0
          • T toxcct

            certainly, ASSERT() was just here to show you that aftrer treatment, the int contains the string's value...


            TOXCCT >>> GEII power
            [toxcct][VisualCalc]

            H Offline
            H Offline
            Halawlaws
            wrote on last edited by
            #5

            okey thx /\|-||\/|/\|)

            1 Reply Last reply
            0
            • H Halawlaws

              I have a CString of 6 numbers how can i cast into one int variable so i can compare it with different numbers. /\|-||\/|/\|)

              M Offline
              M Offline
              Marc Soleda
              wrote on last edited by
              #6

              what about atoi[^]? Marc Soleda. ... she said you are the perfect stranger she said baby let's keep it like this... Tunnel of Love, Dire Straits.

              1 Reply Last reply
              0
              • H Halawlaws

                I have a CString of 6 numbers how can i cast into one int variable so i can compare it with different numbers. /\|-||\/|/\|)

                S Offline
                S Offline
                Smith
                wrote on last edited by
                #7

                copy the string to char then use itoa regards, Rookie

                S 1 Reply Last reply
                0
                • S Smith

                  copy the string to char then use itoa regards, Rookie

                  S Offline
                  S Offline
                  Smith
                  wrote on last edited by
                  #8

                  sorry atoi regards, Rookie

                  E 1 Reply Last reply
                  0
                  • S Smith

                    sorry atoi regards, Rookie

                    E Offline
                    E Offline
                    Eytukan
                    wrote on last edited by
                    #9

                    Rookieee wrote: int i; CString str = "32"; sscanf(str, "%d", &i);ASSERT(i == 32); int i; CString str = "32"; sscanf(str, "%d", &i);ASSERT(i == 32); watz wrong with this ^? vivek

                    T 1 Reply Last reply
                    0
                    • E Eytukan

                      Rookieee wrote: int i; CString str = "32"; sscanf(str, "%d", &i);ASSERT(i == 32); int i; CString str = "32"; sscanf(str, "%d", &i);ASSERT(i == 32); watz wrong with this ^? vivek

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

                      vivekuniq wrote: Rookieee wrote: int i; CString str = "32"; sscanf(str, "%d", &i);ASSERT(i == 32); watz wrong with this ^? sorry but, this sample is mine, not Rookieee's... and of course is works ;P


                      TOXCCT >>> GEII power
                      [toxcct][VisualCalc]

                      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