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. Increment string value in VC++ 6.0

Increment string value in VC++ 6.0

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
11 Posts 8 Posters 1 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.
  • D diptipanchal

    i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

    N Offline
    N Offline
    N a v a n e e t h
    wrote on last edited by
    #2

    diptipanchal wrote:

    The string would contain number only.

    Then why not use numeric datatypes than string?

    Navaneeth How to use google | Ask smart questions

    D 1 Reply Last reply
    0
    • D diptipanchal

      i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

      T Offline
      T Offline
      Tony Pottier
      wrote on last edited by
      #3

      sscanf should do the trick no?

      1 Reply Last reply
      0
      • D diptipanchal

        i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #4

        You first have to convert it to an integer (how to do it depends on what you mean by "string" exactly), increment the integer and then convert it back to a string.

        Cédric Moonen Software developer
        Charting control [v2.0 - Updated] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • D diptipanchal

          i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #5

          Well, it's simple:

          1. Convert the string to a numeric value.
          2. Increment the numeric value
          3. Convert back the numeric value to string

          What are your troubles in doing that? :) Too slow Carlo, too slow... :rolleyes:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • D diptipanchal

            i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #6

            Why can you not just use an integer instead of exploring ways to misuse a string?

            It is a crappy thing, but it's life -^ Carlo Pallini

            J 1 Reply Last reply
            0
            • D diptipanchal

              i need to increment the string value in VC++ 6.0 MFC dialog based application. if the value of the string is 60 then it should get increment to 61. how can i achieve that. The string would contain number only. Pl suggest.

              B Offline
              B Offline
              bulg
              wrote on last edited by
              #7

              i like it. 8 bits for each digit instead of 1/ln(|digit|). how many times are you incrementing?

              1 Reply Last reply
              0
              • R Rajesh R Subramanian

                Why can you not just use an integer instead of exploring ways to misuse a string?

                It is a crappy thing, but it's life -^ Carlo Pallini

                J Offline
                J Offline
                Jim Crafton
                wrote on last edited by
                #8

                Rajesh R Subramanian wrote:

                exploring ways to misuse a string

                Because abusing strings is always a lot more fun!

                ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog Just Say No to Web 2 Point Oh

                CPalliniC 1 Reply Last reply
                0
                • J Jim Crafton

                  Rajesh R Subramanian wrote:

                  exploring ways to misuse a string

                  Because abusing strings is always a lot more fun!

                  ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog Just Say No to Web 2 Point Oh

                  CPalliniC Offline
                  CPalliniC Offline
                  CPallini
                  wrote on last edited by
                  #9

                  Jim Crafton wrote:

                  Because abusing strings is always a lot more fun!

                  Well, exporing double roundings is even more fun... :rolleyes:

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                  [My articles]

                  In testa che avete, signor di Ceprano?

                  J 1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    Jim Crafton wrote:

                    Because abusing strings is always a lot more fun!

                    Well, exporing double roundings is even more fun... :rolleyes:

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    J Offline
                    J Offline
                    Jim Crafton
                    wrote on last edited by
                    #10

                    Oh, you cut me low, you cut me really low... :cool:

                    ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! VCF Blog Just Say No to Web 2 Point Oh

                    1 Reply Last reply
                    0
                    • N N a v a n e e t h

                      diptipanchal wrote:

                      The string would contain number only.

                      Then why not use numeric datatypes than string?

                      Navaneeth How to use google | Ask smart questions

                      D Offline
                      D Offline
                      diptipanchal
                      wrote on last edited by
                      #11

                      I can not define that variable as int as i would need to store the variable value in txt file using CStdioFile. Using this class, it does not allow to store "int" value. *********** EXAMPLE **************** int m_barNo; cfile.WriteString(m_barNo); **************************************** if i try to store the int value using WriteString member function of CStdioFile, it gives an error as below "error C2664: 'WriteString' : cannot convert parameter 1 from 'int' to 'const char *' " Hence i would need to increment string..could anyone suggest how do i proceed...

                      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