Question: CAN U PLEASE ADD SORTING FUNCTION IN THIS CODE. I DON'T HAVE ANY IDEA. FOR MY TO-DO LIST PROJECT. THANK YOU. #include #include #define TRUE

CAN U PLEASE ADD SORTING FUNCTION IN THIS CODE. I DON'T HAVE ANY IDEA. FOR MY TO-DO LIST PROJECT. THANK YOU.

#include #include #define TRUE 1 #define FALSE 0 struct date { int date; int time; };

struct Task { char task[100]; struct date Duedate; struct Task* next; };

struct Task* front=NULL; struct Task* rear=NULL; struct Task* currentptr;

void Enqueue(); void Dequeue(); void Display(); void Search();

int main() { char ch; int choice=TRUE; front=(struct Task *)NULL; while(choice==TRUE) { fflush(stdin); printf(" ---------------------------"); printf(" E - Enter new task "); printf("D - Delete task "); printf("L - List out all tasks "); printf("S - Search a date "); printf("X - Exit "); printf(" Enter your choice: "); scanf("%c",&ch); fflush(stdin); switch(ch) { case 'E':Enqueue();break; case 'e':Enqueue();break; case 'D':Dequeue();break; case 'd':Dequeue();break; case 'L':Display();break; case 'l':Display();break; case 'S':Search();break; case 's':Search();break; case 'X':choice=FALSE;break; case 'x':choice=FALSE;break;

default:printf(" Enter only one from above ");

}

} getch(); return 0; }

void Enqueue() { struct Task* temp=(struct Task*)malloc(sizeof(struct Task)); fflush(stdin); printf("Task : "); scanf("%[^ ]s",&temp->task); fflush(stdin); //Example input for date: ddmmyy (eg:310122) // printf("Due date: "); scanf("%d",&temp->Duedate.date); //Enter time in 24 hour format: 0900; 2300// printf("Due time: "); fflush(stdin); scanf("%d",&temp->Duedate.time); temp->next=NULL;

if(front==NULL && rear==NULL) { front=rear=temp; return; } rear->next=temp; rear=temp; }

void Dequeue() { struct Task*temp=front; if(front==NULL) { printf(" Task list is empty "); return; } if(front==rear) { front=rear=NULL; } else { front=front->next; } free(temp); Display(temp); }

void Display() { if(front==NULL) { printf(" List is empty "); return; } currentptr=front; printf("Task\t\t\t\tDue date\tDue time "); while(currentptr!=NULL) {

printf("%s\t\t\t\t%d\t%d ",currentptr->task,currentptr->Duedate.date,currentptr->Duedate.time); currentptr=currentptr->next;

} printf(" "); printf("*Life is not about having everything. It is about finding meaning in everything.* "); //Motivate quote for user }

void Search() { int search_date;

if(front==NULL) { printf(" List is empty "); }

else { printf(" Enter the due date of the task that you want to search: "); scanf("%d", &search_date);

currentptr = front;

while(currentptr->next!=NULL) { if(currentptr->Duedate.date==search_date) { printf("Task Due Date Due Time "); printf("%s %06d %04d ",currentptr->task, currentptr->Duedate.date, currentptr->Duedate.time); printf(" "); printf("*You never change your life until you step out of your comfort zone; change begins at the end of your comfort zone.* "); //Motivate quote for user return; }

else { currentptr=currentptr->next; } }

if(currentptr->Duedate.date==search_date) { printf("Task Due Date Due Time "); printf("%s %06d %04d ",currentptr->task, currentptr->Duedate.date, currentptr->Duedate.time); printf(" "); printf("*Believe in your infinite potential. Your only limitations are those you set upon yourself.* "); //Motivate quote for user } else { printf(" Sorry, no match found "); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!