create node in c

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

// Define a structure for a node
struct Node {
    int data;           // Data of the node
    struct Node* next;  // Pointer to the next node
};

int main() {
    // Create a new node
    struct Node newNode = (struct Node)malloc(sizeof(struct Node));

    // Check if memory allocation was successful
    if (newNode == NULL) {
        printf("Memory allocation failed. Exiting...\n");
        return 1; // Exit with an error code
    }

    // Assign data to the node
    newNode->data = 42;

    // Set the next pointer to NULL since this is the only node for now
    newNode->next = NULL;

    // Print the data of the node
    printf("Data of the node: %d\n", newNode->data);

    // Free the allocated memory for the node
    free(newNode);

    return 0; // Exit successfully
}