'unsigned char'-C编程中的声明,赋值和用法

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值