What does Z["ack"] = 5 mean?

Ron Natalie ron at ron.rutgers.edu
Thu Oct 6 07:19:54 AEST 1988


You're program is bogus only in the fact that Z is not set to anything
before it is referenced.  Automatic variables are NOT guaranteed to
be set to zero.

	A[B] is equivelent to *(A+B)

This means that in programs like:
	char	a[10];
	int	b;

	b = 1;

	a[b] = '5';
	b[a] = '5';

The last two lines are equivelent.
Note that strings are just character arrays.  So you can do

	"FOOBAR"[3] = 'E';

or even
	3["FOOBAR"] = 'E';

Although it's not clear to me what modifying a string like that
is because your example doesn't show you storing a pointer to
that string anywhere and hence it is not going to be able to
be referenced again.

-Ron



More information about the Comp.lang.c mailing list