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 int to char??

convert int to char??

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 6 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
    Larsson
    wrote on last edited by
    #1

    How can I convert a int to a char??

    S T M C O 5 Replies Last reply
    0
    • L Larsson

      How can I convert a int to a char??

      S Offline
      S Offline
      stolid_rock
      wrote on last edited by
      #2

      use itoa() function

      L 1 Reply Last reply
      0
      • L Larsson

        How can I convert a int to a char??

        T Offline
        T Offline
        ThatsAlok
        wrote on last edited by
        #3

        Larsson wrote: How can I convert a int to a char?? Do u inquring about char * [itoa] if char:simple casting will help!

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta

        L 1 Reply Last reply
        0
        • S stolid_rock

          use itoa() function

          L Offline
          L Offline
          Larsson
          wrote on last edited by
          #4

          How? can you show me an exemple?

          1 Reply Last reply
          0
          • T ThatsAlok

            Larsson wrote: How can I convert a int to a char?? Do u inquring about char * [itoa] if char:simple casting will help!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            L Offline
            L Offline
            Larsson
            wrote on last edited by
            #5

            How?

            T 1 Reply Last reply
            0
            • L Larsson

              How?

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              [code] int nNum=10; char szNum[5]; itoa(nNum,szNum,10);

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

              cheers, Alok Gupta

              L 1 Reply Last reply
              0
              • T ThatsAlok

                [code] int nNum=10; char szNum[5]; itoa(nNum,szNum,10);

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta

                L Offline
                L Offline
                Larsson
                wrote on last edited by
                #7

                Thanks!

                1 Reply Last reply
                0
                • L Larsson

                  How can I convert a int to a char??

                  M Offline
                  M Offline
                  mkuhac
                  wrote on last edited by
                  #8

                  TCHAR szBuffer[16]; INT iValue = 5; ::wsprintf (szBuffer, TEXT("%d"), iValue);

                  1 Reply Last reply
                  0
                  • L Larsson

                    How can I convert a int to a char??

                    C Offline
                    C Offline
                    CodeBeetle
                    wrote on last edited by
                    #9

                    char szNum[30]; int i = 1234; itoa(i,szNum,10); // szNum now = "1234"


                    CodeBeetle.Com


                    1 Reply Last reply
                    0
                    • L Larsson

                      How can I convert a int to a char??

                      O Offline
                      O Offline
                      owillebo
                      wrote on last edited by
                      #10

                      The type safe and portable way Convert any type for which an ostream << operator is defined. template std::string to_string(const T &t) { std::stringstream ss; ss << t; return ss.str(); } Use std::string::c_str() to retrieve char*

                      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