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: Sat, 15 Oct 2016 12:12:06 -0700 Organization: None to speak of Lines: 40 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="d0721e8dde95c3bcc5de2a1c92f543fd"; logging-data="2955"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WHDB8eUj2euFDXZsosS94" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:AlvG61fyFDfplsnoaIX8/cPYiMU= sha1:1PtAqve+rU/Z6vuvKl4EqegjNjo= Xref: csiph.com comp.lang.c:94870 Richard Damon writes: > On 10/11/16 9:55 PM, Keith Thompson wrote: >> Malcolm McLean writes: >>> int buff[1024]; >>> >>> buff is a constant pointer to a buffer (which C mis-terms an "array") >>> which contains enough space for 1024 integers. Except there's a little >>> syntactical quirk. But that can be ignored for now. >> >> If you're trying to demonstrate the idea of being deliberate misleading, >> well done. > > 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. Warning: Pedantic quibbling follows. Strictly speaking `pointer` is const (read-only), not constant (evaluated at compile time). If you want to access the elements of `buffer`, then defining a pointer to its element type is the way to go. If you literally want a pointer to the buffer (assuming that "buffer" means "array object"), you need a pointer to the array type: const int (*p)[1000] = &buffer; but that happens to be less useful. -- 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"