久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

什么是無符號字符?

What is an unsigned char?(什么是無符號字符?)
本文介紹了什么是無符號字符?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 C/C++ 中,unsigned char 用于什么?它與普通的 char 有何不同?

In C/C++, what an unsigned char is used for? How is it different from a regular char?

推薦答案

在 C++ 中,有三種不同的字符類型:

In C++, there are three distinct character types:

  • char
  • 有符號的字符
  • 無符號字符

如果您為 text 使用字符類型,請使用不合格的 char:

If you are using character types for text, use the unqualified char:

  • 它是字符文字的類型,如 'a''0'(僅在 C++ 中,在 C 中它們的類型是 int)
  • 它是組成C字符串的類型,如"abcde"
  • it is the type of character literals like 'a' or '0' (in C++ only, in C their type is int)
  • it is the type that makes up C strings like "abcde"

它也可以作為數字值計算,但未指定該值是被視為有符號還是無符號.當心通過不等式進行字符比較 - 盡管如果您將自己限制為 ASCII (0-127),那么您就很安全了.

It also works out as a number value, but it is unspecified whether that value is treated as signed or unsigned. Beware character comparisons through inequalities - although if you limit yourself to ASCII (0-127) you're just about safe.

如果您將字符類型用作數字,請使用:

If you are using character types as numbers, use:

  • signed char,它給你至少 -127 到 127 的范圍.(-128 到 127 很常見)
  • unsigned char,它給你至少 0 到 255 的范圍.
  • signed char, which gives you at least the -127 to 127 range. (-128 to 127 is common)
  • unsigned char, which gives you at least the 0 to 255 range.

至少",因為 C++ 標準只給出了每個數字類型需要覆蓋的最小范圍的值.sizeof (char) 需要為 1(即一個字節),但理論上一個字節可以是例如 32 位.sizeof 仍會報告其大小為 1 - 這意味著您可以sizeof (char)== sizeof (long) == 1.

"At least", because the C++ standard only gives the minimum range of values that each numeric type is required to cover. sizeof (char) is required to be 1 (i.e. one byte), but a byte could in theory be for example 32 bits. sizeof would still be report its size as 1 - meaning that you could have sizeof (char) == sizeof (long) == 1.

這篇關于什么是無符號字符?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Algorithm to convert RGB to HSV and HSV to RGB in range 0-255 for both(將 RGB 轉換為 HSV 并將 HSV 轉換為 RGB 的算法,范圍為 0-255)
How to convert an enum type variable to a string?(如何將枚舉類型變量轉換為字符串?)
When to use inline function and when not to use it?(什么時候使用內聯函數,什么時候不使用?)
Examples of good gotos in C or C++(C 或 C++ 中好的 goto 示例)
Significance of ios_base::sync_with_stdio(false); cin.tie(NULL);(ios_base::sync_with_stdio(false) 的意義;cin.tie(NULL);)
Is TCHAR still relevant?(TCHAR 仍然相關嗎?)
主站蜘蛛池模板: 亚洲成人国产 | 亚洲一区在线免费观看 | 国产精品婷婷 | 欧美日韩高清 | 成人激情视频网 | 免费看毛片网站 | 黄色成年 | 国产综合亚洲精品一区二 | 日韩一级黄色片 | av一级在线 | 日本免费中文字幕 | 国产精品视频免费 | av一区二区在线观看 | 成人免费看 | 日本免费毛片 | 蜜臀久久99精品久久久 | 91视频色| 欧美精品乱码视频一二专区 | 一级免费片 | 国产精品美女 | 一级黄色片免费 | 色综合天天综合网国产成人网 | 色av吧| 欧美日韩激情视频 | 亚洲精品在线视频观看 | 天天曰天天操 | 亚洲精品成人在线 | 亚洲黄色在线视频 | 91免费网| 成人爱爱 | 成人做受黄大片 | 国产精品日韩欧美 | 毛片在线观看视频 | 色综合一区二区 | a天堂在线视频 | 日韩午夜激情 | 青青草福利视频 | 国产乱码一区二区三区 | 中文字幕一区二区三区在线观看 | 一区二区不卡 | 国产日韩精品一区二区 |