char is a data type in C programming language which can store value from -128 to +127. It generally used to store character values.
char是C编程语言中的数据类型,可以存储从-128到+127的值 。 它通常用于存储字符值。
unsigned is a qualifier which is used to increase the values to be written in the memory blocks. For example - char can store values between -128 to +127, while an unsigned char can store value from 0 to 255 only.
unsigned是一个限定符,用于增加要写入存储块的值。 例如-char可以存储-128到+127之间的值, 而无符号char只能存储0到255之间的值。
unsigned store only positive values, its range starts from 0 to (MAX_VALUE*2)+1.
unsigned仅存储正值,其范围从0到(MAX_VALUE * 2)+1 。
unsigned char is a character data type with larger range of the value than signed char.
unsigned char是字符数据类型,其值范围比signed char大 。
Whenever we work with positive value between the range of 0 to 255, we can use unsigned char instead of short, int type of data type.
只要我们使用0到255之间的正值,就可以使用unsigned char代替数据类型的short , int类型。
Declaration syntax:
声明语法:
unsigned char variable_name;
Declaration example:
声明示例:
unsigned char age;
程序读取并打印C中的未签名char值 (Program to read and print the unsigned char value in C)
#include <stdio.h>
int main()
{
unsigned char age;
printf("Enter age: ");
scanf("%d",&age);
printf("Input age is: %d\n",age);
return 0;
}
Output
输出量
Enter age: 75
Input age is: 75
翻译自: https://www.includehelp.com/code-snippets/unsigned-char-declaration-read-and-print-in-c-language.aspx