Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C Programming Tutorial on Youtube Date: Mon, 17 Oct 2016 12:39:47 -0700 Organization: None to speak of Lines: 32 Message-ID: References: <8be0cdbe-c2f4-42ec-b6a7-e9a154981718@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="5cf263897792072a9f2f11bacfc4852d"; logging-data="13575"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8L0t1q9fZKVSO8o4wXkuK" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:LRLvDwpSoNag0mUArbBz/BohLhA= sha1:WZDtE/wGi/WAth+i1x7YOLHnc7M= Xref: csiph.com comp.lang.c:95014 Ian Collins writes: > On 10/18/16 01:27 AM, Malcolm McLean wrote: >> On Saturday, October 15, 2016 at 3:09:38 AM UTC+1, Richard Damon wrote: >>> On 10/11/16 9:55 PM, Keith Thompson wrote: >>> >>> IF you want a constant pointer to a 'buffer' of ints: >>> >>> >>> int buffer[1024][ >>> >>> int * const pointer = buffer; >>> >>> >>> pointer now IS a constant pointer to the array buffer. accessable int by >>> int. >>> >> Yes, but you almost never need to do that. It's not something you are likely to >> see in any real code. > > It's something you get to see very often in "real code". Traversing a > buffer is a far from uncommon activity. `pointer` is a const pointer, not a pointer to a const target. You can't use it to traverse `buffer`; `pointer++` is a constraint violation. (You could use `pointer + offset` or `pointer[index]`, but then you might as well use `buffer` rather than `pointer`.) -- 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"