Move last element to front of a given Linked List

Problem statement: Given a Singly linked list, move the last element to the front of the linked list.
For example,

 -> 1 -> 2 -> 3 -> 4 -> 5 -> NULL -> 5 -> 1 -> 2 -> 3 -> 4 -> NULL
```/*C code to move the last element to front of the Linked List */
#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
int data;
struct node *next;
} NODE;

NODE *newNode(int key)
{
NODE *temp = (NODE *)malloc(sizeof(NODE));
temp->data = key;
temp->next = NULL;
return temp;
}

void moveToFront()
{

return;
NODE *secLast = NULL;

while (last->next != NULL)
{
secLast = last;
last = last->next;
}

secLast->next = NULL;
}

void printList()
{
if (temp == NULL)
{
printf("List is empty!\n");
return;
}
while (temp != NULL)
{
printf("%d--> ", temp->data);
temp = temp->next;
}
printf("NULL\n");
}

int main()
{
printList();
moveToFront();
printf("Linked list after moving last element to front\n");
printList();
return 0;
}

```
 \$ ./a.out Linked List is 1–> 2–> 3–> 4–> 5–> NULL Linked list after moving last element to front Linked List is 5–> 1–> 2–> 3–> 4–> NULL \$