構造体の配列を作成しました。qsortを使用して日付を日付順にソートするか、char month []を記述する必要があります。どのように私は次のコードを月に応じて構造体を表示させることができます。ご意見をお聞かせください。おかげCプログラミングでqsortを使用してStructをソートする方法
struct dates
{
int index;
int day;
int year;
char month[15];
};
int i=0;
int count = 0 ;
char test ='\0';
int total =0;
printf("Please enter the number of dates you need to display");
scanf("%d",&total);
struct dates *ip[total];
for(count =0; count< total; count++){
ip[count] = (struct dates*)malloc(sizeof(struct dates));
printf("\nEnter the name month.");
scanf("%s", ip[count]->month);
printf("\nEnter the Day.");
scanf("%d",&ip[count]->day);
printf("\nEnter the Year.");
scanf("%d", &ip[count]->year);
}
for(i=0; i<total; i++){
printf("%s %d %d\n\n",ip[i]->month,ip[i]->day,ip[i]->year);
}
あなたは男のqsort' 'を見たことがありますか?ドキュメンテーションはあなたがしなければならないことを説明し、それを使用する方法の例を示します。 –