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. Conversion from int to basic string

Conversion from int to basic string

Scheduled Pinned Locked Moved C / C++ / MFC
jsonquestion
27 Posts 9 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.
  • I itkid

    Hi Friend, Is there any API which convert int(int a) to basic string(string b)? itoa can convert a(int) to char*(Char *c) and I can get b from c.However is there any other way? Thanks :)

    S Offline
    S Offline
    Stephen Hewitt
    wrote on last edited by
    #21

    Here's how I'd go about doing it: ostringstream ss; ss << "PI = " << 3.14159265; string s = ss.str(); Includes you'll need:  <string>  <sstream> Assumes:  using namespace std; Steve

    I 1 Reply Last reply
    0
    • T toxcct

      it indicates that you are at the root directory on the C: drive :rolleyes:

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #22

      I am serious man:| nave

      T A 2 Replies Last reply
      0
      • N Naveen

        I am serious man:| nave

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

        hum, so i didn't understand your question... in MS-DOS, C:\> is the common prompt to tell that you are located on the root directory of the C: drive. the ver command displays the actual version on MS-DOS installed (or windows since WinNT4 - as it doesn't need dos anymore) if i still don't answer your question, please rephrase:^)

        1 Reply Last reply
        0
        • I itkid

          Hi Friend, Is there any API which convert int(int a) to basic string(string b)? itoa can convert a(int) to char*(Char *c) and I can get b from c.However is there any other way? Thanks :)

          J Offline
          J Offline
          jhwurmbach
          wrote on last edited by
          #24

          itkid wrote:

          Is there any API which convert int(int a) to basic string(string b)?

          std::basic_string is a template. You can't convert to it, but only to its instantiations e.g. std::string or std::wstring That said, I would take a look at boost.orgs lexical cast[^] or format[^]. Free but peer-reviewed code. Some of it will be part of the next version of the C++-Standard.


          "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

          1 Reply Last reply
          0
          • N Naveen

            I am serious man:| nave

            A Offline
            A Offline
            Akt_4_U
            wrote on last edited by
            #25

            what is going on here........????? i just confused...:zzz::(( Akkott

            1 Reply Last reply
            0
            • S Stephen Hewitt

              Here's how I'd go about doing it: ostringstream ss; ss << "PI = " << 3.14159265; string s = ss.str(); Includes you'll need:  <string>  <sstream> Assumes:  using namespace std; Steve

              I Offline
              I Offline
              itkid
              wrote on last edited by
              #26

              Thank you very much Steve. It is really usefull. ;)

              1 Reply Last reply
              0
              • I itkid

                Hi Friend, Is there any API which convert int(int a) to basic string(string b)? itoa can convert a(int) to char*(Char *c) and I can get b from c.However is there any other way? Thanks :)

                N Offline
                N Offline
                Nibu babu thomas
                wrote on last edited by
                #27

                C++ Faqs[^]


                Nibu thomas Software Developer

                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