Possible Duplicate:
Arrow operator (->) usage in C
I am trying to figure out the difference between the "." and "->" styles of data access in C language. Eg.
struct div{
int quo;
int rem;
};
1) Using "->"
struct div *d = malloc(sizeof(struct div));
d->quo = 8/3;
d->rem = 8%3;
printf("Answer:\n\t Quotient = %d\n\t Remainder = %d\n-----------\n",d->quo,d->rem);
2) Using "."
struct div d;
d.quo = 8/3;
d.rem = 8%3;
printf("Answer:\n\t Quotient = %d\n\t Remainder = %d\n-----------\n",d.quo,d.rem);
I am getting the same output for both the cases.
Answer: Quotient = 2 Remainder = 2
How these two approaches are working internally? And at what time which one should be used? I tried searching it on the internet but of not much help. Any relevant link is also appreciated.
Also is there any difference between their storage in memory?