caramelleamare caramelleamare - 3 months ago 27
C Question

Bit representation of a C vector

Working in little endian, which is excatly (including eof if there is) the bit representation of a C vector like this?

unsigned char vet[] = {0x0f, 0x05};

Answer

Bit representation of a vector of unsigned chars is not dependent on endianness, because char types are single-byte, while endianness tells you how multiple bytes are arranged in memory.

Therefore, 0x0f would be found at an earlier address in memory than 0x05, producing

0000111100000101

including eof if there is [one]

Unlike C strings and arrays initialized with C strings, arrays initialized with curly brace initializers do not have an end mark.