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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. unsigned char

unsigned char

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

    what's the use of unsigned char? if char is going to be characters?? -a , +a ?? and also tell me who to display it in an AfxMessageBox :( regards, Rookie Installing MFC...2% complete

    R T 2 Replies Last reply
    0
    • S Smith

      what's the use of unsigned char? if char is going to be characters?? -a , +a ?? and also tell me who to display it in an AfxMessageBox :( regards, Rookie Installing MFC...2% complete

      R Offline
      R Offline
      Russell
      wrote on last edited by
      #2

      You can use unsigned char (for example) to read single byte from file without re-interpreter it as integer (positive or negative values). But, In typical programs, the use is quite the same. To use the AfxMessageBox you can use it in the same way of the char. But your question is strange: the string is build with caratchars and they are translated in a defined numerical range: so if you want to display strange values (like 190) you will obtain only strange sign!!

      Merry Christmas
      Have a nice code day ;)

      1 Reply Last reply
      0
      • S Smith

        what's the use of unsigned char? if char is going to be characters?? -a , +a ?? and also tell me who to display it in an AfxMessageBox :( regards, Rookie Installing MFC...2% complete

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

        char is quite bad named because its name confuses too much the newbies. of course, char goes to be used in strings, but first, that's not always true, and secondly, it does not serves only for that. char in C/C++ is simply a signed byte, not more, not less. that means it can be used as a character (in strings), but also as an integer of 8 bits, or as a simple 8 bits array. about the signature, yes, a char is by default signed, which means it contains values between [-128 ; +127]. but usually, the mainly used characters in the ascii tables are under the code 127 (over that, they are called extended char sets). if you want more than that, you'll have to use UNICODE instead of ASCII, which stores a character on 16 bits instead... to display a char string, simply use the "" notation, ,and the compiler will format your variable as needed ('\0' terminated)...


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

        N 1 Reply Last reply
        0
        • T toxcct

          char is quite bad named because its name confuses too much the newbies. of course, char goes to be used in strings, but first, that's not always true, and secondly, it does not serves only for that. char in C/C++ is simply a signed byte, not more, not less. that means it can be used as a character (in strings), but also as an integer of 8 bits, or as a simple 8 bits array. about the signature, yes, a char is by default signed, which means it contains values between [-128 ; +127]. but usually, the mainly used characters in the ascii tables are under the code 127 (over that, they are called extended char sets). if you want more than that, you'll have to use UNICODE instead of ASCII, which stores a character on 16 bits instead... to display a char string, simply use the "" notation, ,and the compiler will format your variable as needed ('\0' terminated)...


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

          N Offline
          N Offline
          Nemanja Trifunovic
          wrote on last edited by
          #4

          toxcct wrote:

          char in C/C++ is simply a signed byte, not more, not less

          It is simply a byte, but it can be signed or unsigned - it is left to compiler implementations to decide. For instance with VC++, char is signed by default unless the option /J is specified.


          My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it. -- modified at 16:10 Saturday 24th December, 2005

          S 1 Reply Last reply
          0
          • N Nemanja Trifunovic

            toxcct wrote:

            char in C/C++ is simply a signed byte, not more, not less

            It is simply a byte, but it can be signed or unsigned - it is left to compiler implementations to decide. For instance with VC++, char is signed by default unless the option /J is specified.


            My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it. -- modified at 16:10 Saturday 24th December, 2005

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

            I'd suggesting creating a typdef as follows: typedef unsigned char to BYTE; BYTE's are pretty useful in walking through raw data streams, manipulating graphics by having to twiddle the bits of various pixels, etc. Read more of what I have to say at http://directx9.blogspot.com/

            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