Thread: unsigned char declaration

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    unsigned char declaration

    Hi

    I understand the declaration "unsigned int" - it simply means that you are going to use only +ve integers starting from 0. But I don't understand what this "unsigned char" declaration is. Let's try to understand with some simple code.

    Here is ASCII table. Normal ASCII runs from 0 to 127 (decimal) and the extended from 0 to 255.

    Could you please help me with it? Thanks a lot.


    Example for Unsigned:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
     	unsigned char a = 100;
     	unsigned char b = a + 59;
     	
     	cout << "enter a = ";
     	cin >> a;
     	
    	cout << b << endl;
     	
     	system("pause");
     	
    }

    Example for signed:
    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    
    {
     	char a = 100;
     	char b = a + 59;
     	
     	cout << "enter a = ";
     	cin >> a;
     	
    	cout << b << endl;
     	
     	system("pause");
     	
    }
    Last edited by jackson6612; 04-15-2011 at 12:59 PM.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 10-06-2009, 09:37 AM
  2. Converting unsigned long array to unsigned char array
    By delvec28 in forum C Programming
    Replies: 2
    Last Post: 09-07-2009, 08:53 PM
  3. invalid conversion from `unsigned char*' to `char*'
    By tux88 in forum C Programming
    Replies: 6
    Last Post: 10-14-2007, 12:25 AM
  4. cast unsigned char* to (the default) signed char*
    By Mario F. in forum C++ Programming
    Replies: 24
    Last Post: 07-27-2007, 10:41 AM
  5. unsigned char vs signed char and range of values
    By Silvercord in forum C++ Programming
    Replies: 5
    Last Post: 01-22-2003, 01:30 PM