Mail Archives: djgpp/2003/01/18/16:31:40
From: | "Lars Hansen" <lars DOT o DOT hansen AT gmx DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | each address in memory "holds" 32 bit ?
|
Date: | Sat, 18 Jan 2003 22:29:29 +0100
|
Organization: | 1&1 Internet AG
|
Lines: | 25
|
Message-ID: | <b0cgvq$ad2$1@news.online.de>
|
NNTP-Posting-Host: | p5083870b.dip0.t-ipconnect.de
|
X-Trace: | news.online.de 1042925370 10658 80.131.135.11 (18 Jan 2003 21:29:30 GMT)
|
X-Complaints-To: | abuse AT online DOT de
|
NNTP-Posting-Date: | 18 Jan 2003 21:29:30 GMT
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 6.00.2800.1106
|
X-MimeOLE: | Produced By Microsoft MimeOLE V6.00.2800.1106
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
#include "stdio.h"
#include "string.h"
int main()
{
int i=10;
int x[10]={0,1,2,3,4,5,6,7,8,9};
memmove(x+2,x+3,sizeof(int)*7);
while(i--) printf("%d,",x[i]);
}
outputs 9,9,8,7,6,5,4,3,1,0
the same version with memmove(x+sizeof(int)*2,x+sizeof(int)*3,sizeof(int)*7);
outputs 0,0,7,6,5,4,3,2,1,0
So is each address a 32 bit "place" or does the compiler "add" sizeof(int)*
automatically?
I had expect x to be an address (so having a range of an (long) int) and
adding an int increases the address by the value of the int so if the next
memory object I want is 2 bytes further away I have to add 2 ?
- Raw text -