reverse list in C

#include<stdio.h>
#include<stdlib.h>

struct Node {
    int data;
    struct Node* next;
};

void reverseList(struct Node head) {
    struct Node* prev = NULL;
    struct Node current = head;
    struct Node* next = NULL;

    while (current != NULL) {
        next = current->next;
        current->next = prev;
        prev = current;
        current = next;
    }

    *head = prev;
}

void printList(struct Node* node) {
    while (node != NULL) {
        printf("%d ", node->data);
        node = node->next;
    }
}

int main() {
    struct Node* head = NULL;

    // Create a sample linked list
    head = (struct Node*)malloc(sizeof(struct Node));
    head->data = 1;

    struct Node second = (struct Node)malloc(sizeof(struct Node));
    second->data = 2;

    struct Node third = (struct Node)malloc(sizeof(struct Node));
    third->data = 3;

    head->next = second;
    second->next = third;
    third->next = NULL;

    printf("Original List: ");
    printList(head);

    reverseList(&head);

    printf("\nReversed List: ");
    printList(head);

    return 0;
}