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: Wed, 17 Aug 2016 09:59:09 -0700 Organization: None to speak of Lines: 54 Message-ID: References: <4628cd2d-9333-4be6-943a-eb593c5c4c12@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="14079"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+12gEk+1vxmmENa++JB/AF" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:93Ot2UA/1bPnRn1R+Vcg6zH3iS0= sha1:2xX5UVGhlx53HAOL3BbIwudt+/M= Xref: csiph.com comp.lang.c:92379 Les Cargill writes: > already5chosen@yahoo.com wrote: >> On Tuesday, August 16, 2016 at 5:20:52 PM UTC+3, Keith Thompson wrote: >>> >>> Your claim that arrays and pointers are the same thing is blatantly >>> incorrect. >> >> The sentence "C arrays and pointers are the same thing" is incorrect >> in fine details. The sentence "C arrays and pointers have nothing in >> common" is blatantly incorrect. > > I believe that "C arrays are the same as 'C' pointers except for > certain constraints" is both correct and complete. No. > Array semantics are a proper subset of pointer semantics. No. Are you talking about array and pointer types? Array and pointer objects? Array and pointer expressions? Array and pointer declarations? Array and pointer values? Do you claim that array semantics are a proper subset of pointer semantics for all those things? If array semantics were a proper subset of pointer semantics, we wouldn't need arrays; we could do everything with just pointers. Please demonstrate how to write a reasonable "hello, world" program, or how to process command-line arguments (argc and argv) without using any arrays, or how to use any of the standard library functions that take string pointers as arguments. Note that in printf("hello, world\n"); the string literal is an array expression. The word "reasonable" is intended to exclude solutions that process each character individually. In int main(int argc, char **argv) argv is a pointer, but it points to the initial element of an array object, and each non-null element of that array object also points to the initial element of an array object. (All those array objects are allocated somehow before main is entered). (It's 2016. I can't believe I still have to argue that arrays are not pointers.) -- 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"