From: "Graham Warren" Newsgroups: comp.os.msdos.djgpp Subject: Puzzling pointer behaviour Date: Sat, 13 Oct 2001 10:25:02 +0100 Organization: Tesco ISP Lines: 48 Message-ID: <9q90ti$8p9$1@epos.tesco.net> NNTP-Posting-Host: 212.140.70.28 X-Newsreader: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello, Thankyou to all who have helped me in the past. I've come across something slightly strange about byte pointers. Can anyone explain this. This small program demonstrates my query. When a byte pointer is made to point to an long int pointer, it actually points to the 8 least significant bits of the long int. Also, when this byte pointer is incremented it points 'left' of its original position. Why is this? /* POINTER.C */ #include int main (void) { int j; unsigned long int dword1 = 0; unsigned long int *ptr_dword1 = &dword1; unsigned char *ptr_byte1; ptr_byte1 = (unsigned char *) ptr_dword1; *ptr_byte1 = 255; /* optional lines */ ptr_byte1 += 2; *ptr_byte1 = 255; for (j = 0; j < 32; j++) { printf ("%i", (*ptr_dword1 & 0x80000000) ? 1 : 0); *ptr_dword1 = *ptr_dword1 << 1; } printf ("\n"); return 0; } /* end */ Thankyou, Graham Warren