Article View: comp.lang.c.moderated
Article #2278Pointer Arithmetic
From: Dan T. Abell
Date: Thu, 14 Mar 1996 02:26
Date: Thu, 14 Mar 1996 02:26
17 lines
1349 bytes
1349 bytes
This may sound like a dumb question, but can someone tell me how C compilers do pointer arithmetic? In particular, consider an integer array p[0], p[1], ... , p[n] whose entry p[k] we might access using *(p + k). I imagine the typical compiler would multiply the size of an integer by k, add the result to p, and then report the integer located at that address. Now for my question: Do most compilers use plain ol' multiplication or do they use bit-shift operators. Also, does the answer depend on the type of the array p? Many thanks, -Dan -- Dan T. Abell A dog is just a dog until he's Department of Physics --- __o standing right in front of you, University of Maryland ---- _`\<,_ ... and then he's Mr. Dog. College Park, MD 20742 --- (*)/ (*) ---Anon. NB: please send e-mail to dabell@quark.umd.edu (NeXTmail OK!)
Technical Details
Message-ID:
<4i805f$47d@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: dabell@dabell-next.umd.edu (Dan T. Abell) Newsgroups: comp.lang.c.moderated Subject: Pointer Arithmetic Date: 13 Mar 1996 20:26:55 -0600 Organization: University of Maryland, College Park Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4i805f$47d@solutions.solon.com> Reply-To: dabell@quark.umd.edu NNTP-Posting-Host: solutions.solon.com