2.single_linked_list
2.single_linked_list
h>
#include <stdlib.h>
struct Node {
int data;
};
if (newNode == NULL) {
exit(1);
newNode->data = data;
newNode->next = NULL;
return newNode;
newNode->next = head;
return newNode;
return newNode;
current = current->next;
current->next = newNode;
return head;
if (head->data == data) {
free(head);
return temp;
current = current->next;
if (current->next != NULL) {
current->next = temp->next;
free(temp);
}
return head;
current = current->next;
printf("NULL\n");
current = current->next;
free(temp);
// Example usage
int main() {
printList(head);
// Delete a node
printList(head);
freeList(head);
return 0;