A byte is the C memory unit used to account for object storage. Each object consists of bytes, and sizeof measures how many bytes it occupies. The character types char, signed char, and unsigned char each occupy exactly one byte; use char for character data and unsigned char as the atom of object representations. section 12.1
Key rules:
- sizeof(char) is 1 by definition, while sizeof(T) gives the size of an object or type T in bytes. section 12.1
- Every object can be viewed as an array of unsigned char with length sizeof(object). section 12.1
- Pointers to character types receive special treatment when accessing object representations. section 12.1
Inspecting an unsigned value
A union can overlay an unsigned value with an unsigned-char array: assign 0xAABBCCDD to val, then print bytes from bytes[0] onward. One observed output is DD, CC, BB, AA. This reveals the machine's byte order, but the order is implementation-defined rather than standardized. section 12.2
typedef union unsignedInspect unsignedInspect;
union unsignedInspect {
unsigned val;
unsigned char bytes[sizeof(unsigned)];
};
unsignedInspect twofold = { .val = 0xAABBCCDD, };
Shows a union whose unsigned value and unsigned-char array occupy the same storage, making the object representation inspectable. section 12.2
Dynamically allocated storage initially appears only as a byte array without an object interpretation; storing a value gives that storage a type. section 13.0






