Mail Archives: djgpp/2000/05/29/13:18:23
Leon wrote:
>
> Hello
> i know one can use pointer arithmetic to advance the read/write location in memory allocated by malloc for example...
>
> Now since the sizeof char is 1 byte - it is possible to use a pointer to char when moving 1 byte at a time.
>
> but what about systems that may have different sizeof char (ie != 1 byte)
There is no such thing. sizeof(char) == 1 by definition.
Your confusion probably comes from not understanding that "byte"
has a long history without any reference to a fixed number of bits.
A byte (or char) may or may not be an octet (8 bits). It has been
common for, as an example, a byte to be 9-bits on many 36-bit machines,
where a char would also be 9 bits. There is an important family of machines,
the PDP-6/10/20 family, on which byte pointers manipulation
instructions were part of the machine instruction set and a byte was any
aggregate of 1-36 bits not crossing word boundaries. A C implementation would
need to use just one of the sizes in the range 8-36 and stick to it, but the
implementors would have the freedom to choose (the natural choice to maintain
arithmetic types close to the machine being 9- or 18-bits).
>
> how would one then be able to move through a memory block by 1 byte only?
>
> With best regards - Leon.
--
Martin Ambuhl mambuhl AT earthlink DOT net
What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams
A thick skin is a gift from God. - Konrad Adenauer
- Raw text -