Lab Project (I)
Lab Project (I)
The TODO List Application is a console-based program developed in C. It allows users to manage
their tasks by providing functionalities to view, create, and delete TODO items. The application
utilizes a linked list data structure to store and organize the tasks.
Features:
a. Welcome Message: Upon starting the program, users are greeted with a welcome message.
b. Menu Options: Users are presented with a menu containing the following options:
See Your ToDo List: Displays the existing tasks in the TODO list.
Create Your ToDos: Allows users to add new tasks to the list.
Delete Your ToDos: Enables users to remove tasks from the list.
c. Viewing Tasks:
The "See Your ToDo List" option displays all the tasks in the TODO list, along with their
respective count numbers.
Implementation Details:
Overview:
The TODO List Application provides users with a simple and efficient way to manage their tasks.
By utilizing a linked list data structure, users can easily view, create, and delete tasks. The
application offers a user-friendly interface, ensuring a smooth experience in managing and
organizing tasks.
Project Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void welcomeUser();
void seeToDo();
void createToDo();
void delToDo();
todo* start;
todo* currentNode;
int main() {
int choice;
welcomeUser();
while (1) {
printf("\n1. See Your ToDo List");
printf("\n2. Create Your ToDos");
printf("\n3. Delete Your ToDos");
printf("\n4. Exit");
printf("\n\nEnter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
seeToDo();
break;
case 2:
createToDo();
break;
case 3:
delToDo();
break;
case 4:
exit(0);
}
}
return 0;
}
void welcomeUser() {
printf("\n\n\n\n\n");
printf("\t----------------------------------------------------------------\n\
n");
printf("\t----------------- WELCOME TO YOUR TODO LIST APP -----------------\
n\n");
printf("\t----------------------------------------------------------------\n\
n\n");
void seeToDo() {
currentNode = start;
if (start == NULL) {
printf("\nEmpty TODO\n\n");
return;
}
int count = 1;
printf("\n");
}
void createToDo() {
char k;
todo* t;
while (1) {
printf("\nWant to add? (y/n): ");
fflush(stdin);
scanf(" %c", &k);
if (k == 'n') {
break;
} else {
if (start == NULL) {
currentNode = (struct todo*)malloc(sizeof(struct todo));
start = currentNode;
printf("\nAdd it..\n");
fflush(stdin);
fgets(currentNode->data, sizeof(currentNode->data), stdin);
currentNode->count = 1;
currentNode->next = NULL;
} else {
currentNode->next = (struct todo*)malloc(sizeof(struct todo));
currentNode = currentNode->next;
printf("\nAdd it..\n");
fflush(stdin);
fgets(currentNode->data, sizeof(currentNode->data), stdin);
currentNode->count = 1;
currentNode->next = NULL;
}
}
}
}
void delToDo() {
int del;
printf("\nEnter the number of the todo you want to remove: ");
scanf("%d", &del);
if (start == NULL) {
printf("Empty TODO\n");
return;
}
if (start->count == del) {
todo* temp = start;
start = start->next;
free(temp);
return;
}
if (current == NULL) {
printf("Invalid todo number\n");
return;
}
previous->next = current->next;
free(current);
}