炭尺寸混乱 [英] char size confusion

查看:118
本文介绍了炭尺寸混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道1个char = 1个字节= 8位(32位系统)。

As per I know that 1 char = 1 byte = 8 bits(32 bit system).

char c=0xffff0000;  //wrong

那么为什么 char 8位以及 8位长度的文件中的每个字符。

then why char allow just 8 bits and also every character in a file also of 8 bit length.

推荐答案

否。 size的char是从定义1。但这并不意味着它总是占用32位/ 8位。

No. The sizeof char is by definition 1. But this does not mean that it occupies 32-bits/8-bits always.


$ 3.9.1 / 1-声明为字符(char)的对象应该是大的
,足以存储
实现的基本字符集的任何成员。

$3.9.1/1- "Objects declared as characters (char) shall be large enough to store any member of the implementation’s basic character set."

似乎有一个混乱,一个字节是8位。

There appears to be a confusion that a byte is 8-bits. The C++ Standard does not mandate this however.

以下是如何在标准$ 1.7 / 1中定义字节

Here's how byte is defined in the Standard $1.7/1


C
+ +内存模型中的基本存储单元是字节。一个字节至少足够大以包含
基本执行
字符集的任何成员,并由一个
连续的位序列
编号组成是
实现定义的

很明显,一个字节不需要总是8位。

As is clear, a byte need not be always 8-bits.

这篇关于炭尺寸混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆