Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!caip!ll-xn!mit-amt!mit-eddie!genrad!decvax!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon Allbery) Newsgroups: net.lang.c,net.micro.pc,net.unix Subject: Pointers vs. arrays: another dumb question... Message-ID: <1242@ncoast.UUCP> Date: Sat, 21-Jun-86 12:52:47 EDT Article-I.D.: ncoast.1242 Posted: Sat Jun 21 12:52:47 1986 Date-Received: Tue, 24-Jun-86 04:02:40 EDT References: <811@bu-cs.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: net.lang.c Organization: North Coast Computer Resources Lines: 28 Xref: linus net.lang.c:8752 net.micro.pc:8411 net.unix:7661 Expires: Okay, I've another dumb question for everyone: In an application I wrote, I use pointers to arrays. Now: If the array is malloc'ed, the correct cast is: (struct foo (*)[]) and you assign the ``pointer to the array'' to a variable. But, if it's in initialized data, you can't do it that way: you can't take a ``pointer to an array''. So the cast is: (struct foo *) BUT: the arrangement in memory is identical! It should be even on tagged architectures, etc.; in fact, (struct foo *) is always wrong, and might conceivably cause problems on a tagged architecture if you're really pointing to an array. So: why isn't the correct type of an array name (struct foo (*)[])? That would make much more clear the meaning of the pointer, and would avoid many of the pointer-vs.-array confusions. --Brandon -- ihnp4!sun!cwruecmp!ncoast!allbery ncoast!allbery@Case.CSNET ncoast!tdi2!brandon (ncoast!tdi2!root for business) 6615 Center St. #A1-105, Mentor, OH 44060-4101 Phone: +01 216 974 9210 CIS 74106,1032 MCI MAIL BALLBERY (part-time)