Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Issue on assigning address to pointers Date: Tue, 24 Nov 2015 09:22:22 -0800 Organization: None to speak of Lines: 22 Message-ID: References: <94145e10-04ec-4e48-94be-77f4c0c18ac2@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="19593"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LWICaUxqJUjecVyIePCFk" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:nH41GorkpGoyi+ZQEH0Bf/8QZhs= sha1:/xh9LtYnORLPvTwG+TZi/ts9h1U= Xref: csiph.com comp.lang.c:77115 John Bode writes: > On Tuesday, November 17, 2015 at 10:49:38 AM UTC-6, Alla _ wrote: [...] >> So >> ptr = arrayname + 5; >> might not be a pointer to the fifth character in a character >> array. This could be found instead using the '&' operator. A pointer >> to the fifth element can be reliably found with: >> ptr = &(arrayname[5]); >> Be warned! >> END OF QUOTE > > On any modern OS with virtual memory, this shouldn't be a problem. On any conforming C implementation, this is absolutely guaranteed not to be a problem. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"