Question on arrays within a struct and sprintf



I have the following code
#define MAX 32
struct A
{
char carr[MAX];
int iarr[MAX];
int i;
};
void main()
{
struct A a;
strcpy(a.carr, "a.carr Test1");
char test[MAX];
strcpy(test, "2Test2");
sprintf(test, "%s", &a.carr); //method1
printf("%s\n", test);
sprintf(test, "%s", a.carr); //method2
printf("%s\n", test);
}
I use sprintf twice. In the first case I pass &a.carr as the argument
and in the second caseI pass a.carr as the argument.
In both the cases, the code works just fine.
Why does it not fail in the first case?
How come &a.carr and a.carr both produce identical results?

I apologize if this is already covered in a faq.

Thanks.

.



Relevant Pages