История изменений
Исправление soomrack, (текущая версия) :
sizeof говорит сколько в типе вмещается char’ов. Он не про байты вообще.
Он про байты. Но ты имел ввиду, что он не про биты.
ISO/IEC 9899:2011 (E)
страница 4
3.6
1 byte addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
2 NOTE 1
It is possible to express the address of each individual byte of an object uniquely.
3 NOTE 2
A byte is composed of a contiguous sequence of bits, the number of which is implementation- defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit.
страница 90
The sizeof operator yields the size (in bytes) of its operand, which may be expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is integer. If the type of the operand is a variable length array typoe, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.
When sizeof is applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1. When applied to an operand that has array type, the result is the total number of bytes in the array.103) When applied to an operand that has structure or union type, the result is the total number of bytes in such an object, including internal and trailing padding.
The value of the result of both operators is implementation-defined, and its type (an unsigned integer type) is size_t, defined in <stddef.h> (and other headers).
Исправление soomrack, :
sizeof говорит сколько в типе вмещается char’ов. Он не про байты вообще.
ISO/IEC 9899:2011 (E)
страница 4
3.6
1 byte addressable unit of data storage large enough to hold any member of the basic character set of the execution environment
2 NOTE 1
It is possible to express the address of each individual byte of an object uniquely.
3 NOTE 2
A byte is composed of a contiguous sequence of bits, the number of which is implementation- defined. The least significant bit is called the low-order bit; the most significant bit is called the high-order bit.
страница 90
The sizeof operator yields the size (in bytes) of its operand, which may be expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is integer. If the type of the operand is a variable length array typoe, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.
When sizeof is applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1. When applied to an operand that has array type, the result is the total number of bytes in the array.103) When applied to an operand that has structure or union type, the result is the total number of bytes in such an object, including internal and trailing padding.
The value of the result of both operators is implementation-defined, and its type (an unsigned integer type) is size_t, defined in <stddef.h> (and other headers).
Исходная версия soomrack, :
sizeof говорит сколько в типе вмещается char’ов. Он не про байты вообще.
ISO/IEC 9899:2011 (E)
страница 90
The sizeof operator yields the size (in bytes) of its operand, which may be expression or the parenthesized name of a type. The size is determined from the type of the operand. The result is integer. If the type of the operand is a variable length array typoe, the operand is evaluated; otherwise, the operand is not evaluated and the result is an integer constant.
When sizeof is applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1. When applied to an operand that has array type, the result is the total number of bytes in the array.103) When applied to an operand that has structure or union type, the result is the total number of bytes in such an object, including internal and trailing padding.
The value of the result of both operators is implementation-defined, and its type (an unsigned integer type) is size_t, defined in <stddef.h> (and other headers).