why wont this work
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
typedef struct list_data LD;
struct list_data
{
int id;
int wage;
int sex;
int age;
};
int arrange_id(const void *e1, const void *e2)
{
LD *a1=(LD *)e1;
LD *a2=(LD *)e2;
return (a1->id - a2->id);
}
int arrange_wage(const void *e1, const void *e2)
{
LD *a1=(LD *)e1;
LD *a2=(LD *)e2;
return (a1->wage - a2->wage);
}
int arrange_age(const void *e1, const void *e2)
{
LD *a1=(LD *)e1;
LD *a2=(LD *)e2;
return (a1->age - a2->age);
}
int main (void)
{
int b, i;
LD a[10],
char sort;
printf("please enter the number of people that you wish to enter\n");
scanf("%d",&b);
printf("The number of people you will enter is =%d\n\n", b);
printf("Now enter the data\n\r");
for (i=0; i<b; i++)
{
printf("please enter the ID of (person %d)\n", i);
scanf("%d",&a[i].id);
printf("please enter the Wage of (person %d)\n", i);
scanf("%d",&a[i].wage);
printf("please eter the Sex,(0 for male, 1 for female) of (person %d)\n", i);
scanf("%d",&a[i].sex);
printf("please enter the Age of (person %d)\n", i);
scanf("%d",&a[i].age);
}
printf("thank you the data will now be put into a table\n\r");
printf("Results\n\r");
printf("___________________________________\n\r");
printf("ID\t");
printf("Wage\t");
printf("Sex\t");
printf("Age\t\n\r");
for (i=0; i<b; i++)
{
printf("%d\t",a[i].id);
printf("%d\t",a[i].wage);
printf("%d\t",a[i].sex);
printf("%d\t\n",a[i].age);
}
char sort;
int t;
t=1;
while(t==1)
{
printf("How would you like to sort the inputted data?\n\r");
printf("If you want to sort ascending by ID, type 'a'\n\r");
printf("if you want to sort ascending by Wage, type 'b'\n\r");
printf("if you want to sort ascending by age, type 'c'\n\r");
printf("if you want to sort only females, type 'd'\n\r");
printf("if you want to sort only males type 'e'\n\r");
scanf("%c",&sort);
if(sort==a)
{
qsort(a, b, sizeof(LD), arrange_id);
}
else
{
if(sort==b)
{
qsort(a, b, sizeof(LD), arrange_wage);
}
else
{
if(sort==c)
{
qsort(a, b, sizeof(LD), arrange_age);
}
else
{
if(sort==d)
{
/*insert sort here*/
}
else
{
/*insert sort here*/
}
}
}
}
printf("would you like sort again\n '1' = yes\n '2' = no\n\r");
scanf("%d",&t);
}
return 0;
}