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: Difference between these pointer syntaxes Date: Thu, 18 Aug 2016 10:49:54 -0700 Organization: None to speak of Lines: 37 Message-ID: References: <87y441a697.fsf@bsb.me.uk> <87r39s8w6c.fsf@bsb.me.uk> <4991b886-1f54-4098-bf57-ba59710b99d1@googlegroups.com> <87bn0rut34.fsf@bsb.me.uk> <9283b112-8250-4e0b-b149-6ca728a3200b@googlegroups.com> <6566be1f-775c-4a04-abc3-7e77c32dc90b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="23806"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yUdt9QKAv14ZH4xgAdXUQ" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Vf9NM1S4aUQdufyRWGHxk8H6fyg= sha1:/qIQ0jGJPADYp5+e/8FGZI4SvfY= Xref: csiph.com comp.lang.c:92468 BartC writes: [...] > OK, what can you deduce from this expression: > > A[i][j]; > > about the data structures involved? Assume this yields a value of type T. About as much as you can deduce from x = y + z; Even ignoring arrays and pointers, there are a large number of possible combinations of types for x, y, and z. Integer (signed or unsigned) floating-point, complex, with implicit conversions galore. Throw pointers into the mix and either both x and y are pointers (possibly decayed array expressions), or the author is being perverse by using "integer+pointer" rather than "pointer+integer". I don't expect to be able to understand every expression without knowing something about its operands. In the case of `A[i][j]`, I expect that i and j are integers and that A is probably poorly named. If i and j *aren't* integers, I will blame the author of the code for being (perhaps deliberately) unclear. Assuming that i and j are integers, I believe there are 4 possibilities: array of arrays, array of pointers, pointer to array, pointer to pointer. Finding out which is a simple matter of looking at the declaration. -- 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"