hi i am trying to use qsort on a structure holding dates, i am trying to sort years out first but not having much luck i have in my code incompatible pointer... it is to do with my qsort in main can anyone tell me what am doing wrong please
struct dates { int index; int day; int year; char month[15]; }; int cmp(const struct dates* p1, const struct dates* p2) { if(p1 -> year < p2 -> year) { return -1; } else if(p1 -> year > p2 -> year) { return 1; } else return 0; } int main() { int n; scanf("%d", & n); struct dates *date[n]; for(int i = 0; i < n; i++) { date[i] = (struct dates*)malloc(sizeof(struct dates)); scanf("%s %d2 %d2", date[i]->month, & date[i]->day, & date[i]->year); } qsort(date, n, sizeof(*date), cmp); for(int i=0; i<n; i++) { printf("%s %d2 %d2\n\n",date[i]->month, date[i]->day, date[i]->year); } }