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. convert integer number to string text

convert integer number to string text

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

    Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

    -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

    C L H J K 5 Replies Last reply
    0
    • K KARFER

      Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

      -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      you may use the function sprintf function, for instance

      int i;
      char buffer[20];/* just make sure the buffer is big enough */
      i=7;
      sprintf(buffer,"%d", i);

      or, if you prefer the CString class

      int i;
      CString str;
      i=7;
      str.Format("%d", i);

      :)

      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.
      [my articles]

      K 1 Reply Last reply
      0
      • K KARFER

        Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

        -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        CP holds some articles on number-to-text conversion. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Happy 2008!


        1 Reply Last reply
        0
        • K KARFER

          Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

          -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

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

          And see The Complete Guide to C++ Strings, Part II - String Wrapper Classes[^] for other converts.

          1 Reply Last reply
          0
          • K KARFER

            Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

            -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

            J Offline
            J Offline
            Joan M
            wrote on last edited by
            #5

            If I understood you well, you are asking how to get the name of the number, not the number itself inside a string. So you are not asking for: int iNumberSeven = 7; CString csAux = ""; csAux.Format("%i",iNumberSeven); you are asking for something like: if (iNumberSeven == 7) { csAux = "seven"; } If you meant the second option, the only way I can think of is to try to generate the numbers programmatically. And this would mean to study the way the numbers are formed and of course having some basic strings in a vault in order to be able to use them.

            1 Reply Last reply
            0
            • C CPallini

              you may use the function sprintf function, for instance

              int i;
              char buffer[20];/* just make sure the buffer is big enough */
              i=7;
              sprintf(buffer,"%d", i);

              or, if you prefer the CString class

              int i;
              CString str;
              i=7;
              str.Format("%d", i);

              :)

              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.
              [my articles]

              K Offline
              K Offline
              KARFER
              wrote on last edited by
              #6

              O.K Thank's For all

              I'll Be There

              1 Reply Last reply
              0
              • K KARFER

                Hi all please how i can convert integer number to string text like this (i entered 7 in keyboard and the output will be seven) thank's for all

                -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

                K Offline
                K Offline
                KARFER
                wrote on last edited by
                #7

                Thank's For all

                Never put off till tomorrow what can be done today

                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