#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
char data;
struct Node* next;
} Node;
typedef struct LinkedList {
Node* head;
} LinkedList;
void initializeList(LinkedList* list) {
list->head = NULL;
}
void insertElement(LinkedList* list, char data) {
Node* newNode = (Node*)malloc(sizeof(Node));
newNode->data = data;
newNode->next = NULL;
if (list->head == NULL) {
list->head = newNode;
} else {
Node* current = list->head;
while (current->next != NULL) {
current = current->next;
}
current->next = newNode;
}
}
void deleteSecondElement(LinkedList* list) {
if (list->head == NULL || list->head->next == NULL) {
return;
}
Node* second = list->head->next;
list->head->next = second->next;
free(second);
}
int isListEmpty(LinkedList* list) {
return (list->head == NULL);
}
void printList(LinkedList* list) {
Node* current = list->head;
while (current != NULL) {
printf("%c ", current->data);
current = current->next;
}
printf("\n");
}
int main() {
LinkedList list;
initializeList(&list);
insertElement(&list, 'a');
insertElement(&list, 'b');
insertElement(&list, 'c');
deleteSecondElement(&list);
if (!isListEmpty(&list)) {
printList(&list);
}
return 0;
}