久久久久久久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 | www.三级 | 91免费福利视频 | 美女黄色免费网站 | 成人91看片 | 色综合一区二区 | 欧美一区二区三区免费 | 中文字幕免费看 | 狠狠操影院 | 成人午夜在线视频 | 亚洲视频中文字幕 | 久久久久久99精品久久久 | 日日操夜夜骑 | 国产盗摄视频 | 欧美激情一区二区三区 | 国产精品一区二区av | 中文字幕av一区二区 | 成人激情视频网 | 一区二区三区四区精品 | 免费国产精品视频 | 91av在线看 | 亚洲视频一区二区三区四区 | 伊人av在线 | 成人一级黄色片 | 国产免费无遮挡 | 国产视频一区在线 | 五月激情网站 | 黄色av免费看 | 丁香激情网 | 怡红院亚洲 | 国产性猛交 | 一区二区高清视频 | 久久精品欧美一区二区三区不卡 |