'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
總結
以上是生活随笔為你收集整理的'unsigned char'-C编程中的声明,赋值和用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颐和园绕一圈多长时间
- 下一篇: 散列碰撞_散列中的碰撞和碰撞解决技术