Address of array

Steven Brian McKechnie Sargent sbs at valid.UUCP
Thu Apr 17 15:11:22 AEST 1986


> In article <260 at peregrine.UUCP> mike at peregrine.UUCP (Mike Wexler) writes:
> >In article <58 at paisley.ac.uk> rh at cs.paisley.ac.uk (Robert Hamilton) writes:
> >>
> >>	(Much flamage about "right" way to interpret cettes choses)
> >	(Much flamage about "right" way to interpret cettes choses)
>	(Much flamage about "right" way to interpret cettes choses)

The ANSI debate on the C standard, which has devolved into a wide variety
of entertaining circuses, recently had a sidelight into the &array issue.
When I last left it, the committee was leaning toward allowing &array so that
programmers could portably declare and use thusly:

	typedef int time_t[2];
	...
	time_t t;
	printf("%s", (time(&t), ctime(&t)));

(This objection is rather neatly removed by

	typedef struct {
		int once_upon_a[2];
	} time_t;

but never mind.
)

I lean in the opposite direction (I believe that &array is an undesirable
construct) because of the following gotcha:

	char a[200][40];
	char *b[200];
	...
	strcpy(b[i], a[i]);	/* works */
	strcpy(b[i], &a[i]);	/* works */
	strcpy(&b[i], &a[i]);	/* don't work */

Of course, adherents to strong typing will say, "Thou fool.  Declare
strcpy(char *, char *) in thy headers," and they're perfectly entitled
to their opinions.


S.



More information about the Comp.lang.c mailing list