靚麗時尚館

位置:首頁 > 健康生活 > 心理

c++如何檢視位元組

心理1.85W
c++如何檢視位元組

位元組在電腦科學領域,位元組指的是8位記憶體單元,常用byte/B表示,是度量計算機儲存空間大小的度量單位。我們說的1KB就是1024個位元組,即1024*8位。

在C++裡,位元組定義稍有不同。一個位元組包含的位數可表示的狀態(例如8位可表示的狀態是256種)應足以覆蓋基本字符集(ASCII)字元的個數。通常的C++實現中使用的字元系統是ASCII,所以在通常C++實現中,一個位元組就是8位。但是在一些採用Unicode字元系統的C++實現中,可能使用16位或者32位位元組。

#include<iostream>

#include <limits>

using namespace std

int main()

{

cout << "type: tt" << "************size**************"<< endl

cout << "bool: tt" << "所佔位元組數:" << sizeof(bool)

cout << "t最大值:" << (numeric_limits<bool>::max)()

cout << "tt最小值:" << (numeric_limits<bool>::min)() << endl

cout << "char: tt" << "所佔位元組數:" << sizeof(char)

cout << "t最大值:" << (numeric_limits<char>::max)()

cout << "tt最小值:" << (numeric_limits<char>::min)() << endl

cout << "signed char: t" << "所佔位元組數:" << sizeof(signed char)

cout << "t最大值:" << (numeric_limits<signed char>::max)()

cout << "tt最小值:" << (numeric_limits<signed char>::min)() << endl

cout << "unsigned char: t" << "所佔位元組數:" << sizeof(unsigned char)

cout << "t最大值:" << (numeric_limits<unsigned char>::max)()

cout << "tt最小值:" << (numeric_limits<unsigned char>::min)() << endl

cout << "wchar_t: t" << "所佔位元組數:" << sizeof(wchar_t)

cout << "t最大值:" << (numeric_limits<wchar_t>::max)()

cout << "tt最小值:" << (numeric_limits<wchar_t>::min)() << endl

cout << "short: tt" << "所佔位元組數:" << sizeof(short)

cout << "t最大值:" << (numeric_limits<short>::max)()

cout << "tt最小值:" << (numeric_limits<short>::min)() << endl

cout << "int: tt" << "所佔位元組數:" << sizeof(int)

cout << "t最大值:" << (numeric_limits<int>::max)()

cout << "t最小值:" << (numeric_limits<int>::min)() << endl

cout << "unsigned: t" << "所佔位元組數:" << sizeof(unsigned)

cout << "t最大值:" << (numeric_limits<unsigned>::max)()

cout << "t最小值:" << (numeric_limits<unsigned>::min)() << endl

cout << "long: tt" << "所佔位元組數:" << sizeof(long)

cout << "t最大值:" << (numeric_limits<long>::max)()

cout << "t最小值:" << (numeric_limits<long>::min)() << endl

cout << "unsigned long: t" << "所佔位元組數:" << sizeof(unsigned long)

cout << "t最大值:" << (numeric_limits<unsigned long>::max)()

cout << "t最小值:" << (numeric_limits<unsigned long>::min)() << endl

cout << "double: t" << "所佔位元組數:" << sizeof(double)

cout << "t最大值:" << (numeric_limits<double>::max)()

cout << "t最小值:" << (numeric_limits<double>::min)() << endl

cout << "long double: t" << "所佔位元組數:" << sizeof(long double)

cout << "t最大值:" << (numeric_limits<long double>::max)()

cout << "t最小值:" << (numeric_limits<long double>::min)() << endl

cout << "float: tt" << "所佔位元組數:" << sizeof(float)

cout << "t最大值:" << (numeric_limits<float>::max)()

cout << "t最小值:" << (numeric_limits<float>::min)() << endl

cout << "size_t: t" << "所佔位元組數:" << sizeof(size_t)

cout << "t最大值:" << (numeric_limits<size_t>::max)()

cout << "t最小值:" << (numeric_limits<size_t>::min)() << endl

cout << "string: t" << "所佔位元組數:" << sizeof(string) << endl

// << "t最大值:" << (numeric_limits&ltstring>::max)() << "t最小值:" << (numeric_limits<string>::min)() << endl

cout << "type: tt" << "************size**************"<< endl

return 0

標籤:檢視 位元組