0% found this document useful (0 votes)
115 views

Lab Project (I)

The TODO List Application allows users to manage tasks using a console-based linked list implementation. It greets users and displays a menu to view, create, and delete TODO items. The linked list stores task descriptions and counts, utilizing dynamic memory allocation and handles input/output through scanf and fgets functions. The application provides a simple way to organize tasks through an error-checked interface.

Uploaded by

Dr. Han
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Lab Project (I)

The TODO List Application allows users to manage tasks using a console-based linked list implementation. It greets users and displays a menu to view, create, and delete TODO items. The linked list stores task descriptions and counts, utilizing dynamic memory allocation and handles input/output through scanf and fgets functions. The application provides a simple way to organize tasks through an error-checked interface.

Uploaded by

Dr. Han
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Project Brief: TODO List Application

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:

a. Data Structure: The TODO list is implemented using a linked list.


b. Global Variables: The program uses global variables start and currentNode to keep track of the
starting point and the current position in the linked list.
c. Dynamic Memory Allocation: Memory allocation functions (malloc and free) are used to create
and release memory for the todo nodes.
d. Input Handling: The program uses scanf and fgets functions to handle user input for task
descriptions and menu choices.
e. Error Handling: The program includes error checking and appropriate error messages for
invalid
user inputs or edge cases.

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();

typedef struct todo {


char data[100];
int count;
struct todo* next;
} todo;

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;

while (currentNode != NULL) {


printf("%d) %s\n", count, currentNode->data);
currentNode = currentNode->next;
count++;
}

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;
}

todo* current = start;


todo* previous = NULL;

while (current != NULL && current->count != del) {


previous = current;
current = current->next;
}

if (current == NULL) {
printf("Invalid todo number\n");
return;
}

previous->next = current->next;
free(current);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy