From: myknees AT aol DOT com (Myknees) Newsgroups: comp.os.msdos.djgpp Subject: Re: GCC and pointers : QUESTION Lines: 17 Message-ID: <1998080722171300.SAA10608@ladder01.news.aol.com> NNTP-Posting-Host: ladder01.news.aol.com Date: 07 Aug 1998 22:17:13 GMT References: Organization: AOL http://www.aol.com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article , Endlisnis writes: >On Wed, 29 Jul 1998, Inquisitor Nikodemus wrote: >->During writing a function I noticed that operations - such as addition >->or substraction - on pointers of different types than char didn't >->behave as I expected them to. Eg. adding 2 to the the pointer : >-> short *pointer_to_short ; >->resulted in 4 byte offset,not 2 byte. Same for ints etc. >->So the question is : is it really a fact,that gcc's pointer math >->depends on type rather than raw bytes ? > That's how it is in all ANSI C++ compilers. Even pre-ANSI. I read the original Kernighan & Ritchie book, and they said that that is just how the C language works. It's a feature of the language. --Ed (Myknees)