When using malloc and doing similar memory manipulation can I rely on sizeof( char ) being always 1?
For example I need to allocate memory for N elements of type
From "New C standard. An economic and cultural commentary".
char
and 1.5% - from unsigned char
. Page 1033 in 1.2 version of book.The number of bits in the representation of a character type is irrelevant. By definition the number of bytes in byte a character type is one.
Coding Guidelines Developers sometimes associate a byte as always containing eight bits. On hosts where the character type is 16 bits, this can lead to the incorrect assumption that applying sizeof to a character type will return the value 2. These issues are discussed elsewhere.