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. Converting int to char

Converting int to char

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

    Hello, I have the Ascii Code from a character, for example: 101, which is e. How can I convert this int Value into a char or better CString ? With best regards, RedDragon2kx

    S D G 3 Replies Last reply
    0
    • R RedDragon2k

      Hello, I have the Ascii Code from a character, for example: 101, which is e. How can I convert this int Value into a char or better CString ? With best regards, RedDragon2kx

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

      itoa for int to string never say die

      R 1 Reply Last reply
      0
      • S sunit5

        itoa for int to string never say die

        R Offline
        R Offline
        RedDragon2k
        wrote on last edited by
        #3

        Sorry but I think I wasn't clear enough. I need the integer(101) represtented as a char(e). So I need to convert the ASCII code(101) back to the character it represents

        V S 2 Replies Last reply
        0
        • R RedDragon2k

          Sorry but I think I wasn't clear enough. I need the integer(101) represtented as a char(e). So I need to convert the ASCII code(101) back to the character it represents

          V Offline
          V Offline
          vikas amin
          wrote on last edited by
          #4

          int asc_int; CString S_temp; S_temp.Format("%c",asc_int); thats it :cool: Vikas Amin Embin Technology Bombay vikas.amin@embin.com

          R 1 Reply Last reply
          0
          • R RedDragon2k

            Sorry but I think I wasn't clear enough. I need the integer(101) represtented as a char(e). So I need to convert the ASCII code(101) back to the character it represents

            S Offline
            S Offline
            sunit5
            wrote on last edited by
            #5

            what i understood is that u want to convert the ASCII value into char char c=char(101); another way int i= 101;

            char=static_cast<char>(101);

            but keep in mind with range of c never say die -- modified at 6:15 Thursday 29th December, 2005

            1 Reply Last reply
            0
            • V vikas amin

              int asc_int; CString S_temp; S_temp.Format("%c",asc_int); thats it :cool: Vikas Amin Embin Technology Bombay vikas.amin@embin.com

              R Offline
              R Offline
              RedDragon2k
              wrote on last edited by
              #6

              Thank you to you both.

              1 Reply Last reply
              0
              • R RedDragon2k

                Hello, I have the Ascii Code from a character, for example: 101, which is e. How can I convert this int Value into a char or better CString ? With best regards, RedDragon2kx

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                If you remember that a char is just an int with a smaller range, then assigning an int to a char is just that, a simple assignment.


                "Take only what you need and leave the land as you found it." - Native American Proverb

                1 Reply Last reply
                0
                • R RedDragon2k

                  Hello, I have the Ascii Code from a character, for example: 101, which is e. How can I convert this int Value into a char or better CString ? With best regards, RedDragon2kx

                  G Offline
                  G Offline
                  Gary R Wheeler
                  wrote on last edited by
                  #8

                  int i_value;
                  char c_value;
                  c_value = static_cast<char>(i_value);


                  Software Zen: delete this; // [Fold With Us!](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx)[[^](http://www.codeproject.com/script/profile/whos_who.asp?msg=1307432&id=10338#xx1307432xx "New Window")]

                  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