www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/29/13:18:23

Message-ID: <39322CCB.ABE07D4F@earthlink.net>
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Organization: Nocturnal Aviation
X-Mailer: Mozilla 4.73 [en] (Win95; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: advance in allocated memory by 1 byte only
References: <01BFC967 DOT 2C9F11E0 AT LEON DOT caresystems DOT com DOT au>
Lines: 36
Date: Mon, 29 May 2000 08:38:49 GMT
NNTP-Posting-Host: 63.23.136.58
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: newsread1.prod.itd.earthlink.net 959589529 63.23.136.58 (Mon, 29 May 2000 01:38:49 PDT)
NNTP-Posting-Date: Mon, 29 May 2000 01:38:49 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019