Pointers, Structs, and Arrays

Pete Holsberg pjh at mccc.UUCP
Tue May 9 07:52:43 AEST 1989


I ran across the following code and, although I've figured out what it does,
I'm not sure how to explain the notation.

struct foo
{
	char bar[20];
} list[100];

init()
{
	int i;
	for (i=0; i<100; ++i)
		*list[i].bar = '\0';
}

Now I know that the last line points to the first character in the bar array
In each struct variable, but how?  If bar = &bar[0], how so the '*' and the
'&' "get together" to make the last line equivalent to
		list[i].bar[0]
??
-- 
Pete Holsberg                   UUCP: {...!rutgers!}princeton!mccc!pjh
Mercer College				CompuServe: 70240,334
1200 Old Trenton Road           GEnie: PJHOLSBERG
Trenton, NJ 08690               Voice: 1-609-586-4800



More information about the Comp.lang.c mailing list