i need to make a calender (like a to-do list) and i need to sort the months in it.
i have a struct :
typedef struct
{
char name[3];
int month_num;
int day_num;
int day_size; // amount of days that are field in with tasks.
char task[40];
}month; // each month contains a name, its num in the calendar and days.
in order to sort the months, so that it will be easier, i decided to sort it by thier numbers. what i mean is that im calling Jan as the number 1, Feb as the number 2, etc. but since i have the struct i kinda lost in the way with all the names and all the elemnts.
i manged to give all the months thier numbers: (it's a little bit long, so i'll show the few first)
if (strcmp(mName, "jan") == 0)
{
mon[monthcounter].month_num = 1;
}
else if (strcmp(mName, "feb") == 0)
{
mon[monthcounter].month_num = 2;
}
else if (strcmp(mName, "mar") == 0)
{
mon[monthcounter].month_num = 3;
}
else if (strcmp(mName, "apr") == 0)
{
mon[monthcounter].month_num = 4;
}
else
{
printf("Invalid month\n");
}
//etc.
and now to make to sorting it self i've lost in the way. ( i do know how to make a regular swap function that recieves 2 intgeres or with an array, but i asume that here it is not the same...)
i'll really apreciate the help!