Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: static char (*b)[6]; /* an unusual declaration */ Message-ID: <116@xyzzy.UUCP> Date: Sat, 27-Jun-87 13:40:23 EDT Article-I.D.: xyzzy.116 Posted: Sat Jun 27 13:40:23 1987 Date-Received: Sun, 28-Jun-87 04:47:26 EDT References: <761@bsu-cs.UUCP> <2117@dg_rtp.UUCP> <207@sugar.UUCP> Organization: Data General, RTP NC. Lines: 34 > peter@sugar.UUCP (Peter DaSilva) >> throopw@xyzzy.UUCP (Wayne Throop) >> [ static char (*b)[6]; is a ] >> Static pointer to an array of six characters. The same memory layout >> (though *not* the same type) can be had by the declarations: >> char q[6]; >> static char *r = q; > except that static char (*b)[6] doesn't actually allocate the 6 bytes. Well, now, I had already said this in the text immediately following, which Peter removed. To quote myself: Note that the array of characters in the first example does *not* have static scope (and is in fact not even allocated). > Better would be > typedef char mytype[6]; > static mytype *b; But this misses the entire point. Peter has defined a type that is exactly the same as the original declaration of b with type (char (*)[6]). The point was to show that a simple (char *) could indicate the same memory layout, while (obviously) not being the same type. Again, the typedef just above does indeed indicate the same memory layout. But it is *exactly* the same type, and does nothing to clarify the standard confusion, in particular the erronious opinion that (char **) and (char (*)[6]) indicate the same memory structure. It is important to note that they do NOT. -- Adam and Eve had many advantages, but the principal one was, that they escaped teething. --- Pudd'nhead Wilson's Calendar (Mark Twain) -- Wayne Throop !mcnc!rti!xyzzy!throopw