I got the same values by replacing the line marked with (1) in my actual code with:
Date *ptrdate = malloc(12 * sizeof(*ptrdate));
Question: Which one is better and why?
Here is my actual code:
typedef struct {
int day;
int mo;
} Date;
void main(){
Date *ptrdate = malloc(12 * sizeof(Date)); //(1)
ptrdate[0].day=26;
ptrdate[0].mo=5;
printf("Date:%d/%d\n", ptrdate[0].day, ptrdate[0].mo);
}