Thread: char vs unsigned char?

  1. #1
    Shadow12345
    Guest

    char vs unsigned char?

    what is the difference between a char and an unsigned char?

    Also is char* used for returning an array of characters?

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    yes, char * can be used to return a null terminated char array. But be careful, this can lead to errors related to scope if not used properly.

    As to char vs unsigned char, I believe it goes thusly. The char type routinely is assigned 1 byte of memory. Each byte of memory contains 8 bits of memory. Each bit can be thought of as either a 0 or a 1 in binary memory. Therefore each byte can store 2^8 or 256 different combinations of 0s and 1s or 256 binary numbers. But which 256 numbers should be used. If you use signed char type, which is the default I believe, then the numbers range from -127 to 128, and usually just the range from 0 to 128 is used. If you use unsigned char then the range is from 0 to 255. The 0-128 is used for the standard ASCII char set, and the 0-255 range is used for the extended ASCII char set. Or at least thats what I think the situation is.

  3. #3
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    603
    To quote my C++ programmers reference...

    Whether char is signed or unsigned is implementation dependant
    ...... whatever that means!
    Visit entropysink.com - It's what your PC is made for!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 06-16-2006, 09:23 PM
  2. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 05:59 AM
  3. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM
  4. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM
  5. ANY BODY WILLING TO HELP ME WITH Microsoft Visual C++
    By BiG pImPiN fOoL in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2001, 06:03 PM