I have written following program .
#include<stdio.h>
#include<stdlib.h>
struct Test
{
int count;
};
void main()
{
struct Test *ptr;
struct Test test;
ptr = malloc(sizeof(struct Test));
if ( ptr)
{
ptr->count = 123;
test.count = 456;
printf("count : %d ",(*ptr).count);
printf("count : %d ",(&test)->count);
}
else
{
printf(" malloc failed \n");
}
}
output of the program: count : 123 count : 456
Can anyone please explain how to represent (*ptr).count and (&test)->count in this code and how it is working ?