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 of ascii to char in vc++

conversion of ascii to char in vc++

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
6 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.
  • U Offline
    U Offline
    User 1586251
    wrote on last edited by
    #1

    11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

    C T K N J 5 Replies Last reply
    0
    • U User 1586251

      11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      converting int to char is implicit, it happens by itself. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • U User 1586251

        11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

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

        a char in C/C++ is only an integer which contain the ascii code (1 byte so) of the character it stores. so, writing the two following lines is equal :

        char c = 57;

        char c = 0x39;

        char c = '9';


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        1 Reply Last reply
        0
        • U User 1586251

          11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

          K Offline
          K Offline
          kakan
          wrote on last edited by
          #4

          [Message Deleted]

          1 Reply Last reply
          0
          • U User 1586251

            11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

            N Offline
            N Offline
            normanS
            wrote on last edited by
            #5

            Since you mention codes 128 - 255, it is probably better to use unsigned char, since char will be negative in that range. As other replies have said, char and ASCII codes are the same thing. You can see either a character or a numeric value when using printf (or whatever other output). To see the difference, try the following: char cMyChar; unsigned char ucMyUnsignChar; uMyChar = 77; // ASCII for "M" ucMyUnsignChar = 77; printf ("Character is %c, value is %i, unsigned is %c, unsign value is %i.\n",uMyChar,uMyChar,ucMyUnsignChar,ucMyUnsignChar); ucMyChar = 220; // Some "upper ASCII" character ucMyUnsignChar = 220; printf ("Character is %c, value is %i, unsigned is %c, unsign value is %i.\n",uMyChar,uMyChar,ucMyUnsignChar,ucMyUnsignChar); NOTE: I'm not sure if this is correct - I don't have access to a C compiler on my office PC. I'm sure others will help!

            1 Reply Last reply
            0
            • U User 1586251

              11:46 am IST Monday Aug 29, 2005 Good Morning, How can I convert ascii code to char in vc++ for ascii codes between 128 - 255.

              J Offline
              J Offline
              John R Shaw
              wrote on last edited by
              #6

              5:20 am EST USA What the other respondents are saying is correct, there realy is no conversion required. I suspect that your probably having a character set (font) problem. INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen

              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