I am very new to C but have experience with languages such as Java and Python. I have a small code segment where I am trying to implement a stack pop operation. My question is how do I indicate that the pop failed because the linked list was empty? Should I put some special "error" value in the integer variable where the popped values is supposed to go? I'd appreciate if you can find any other flaws in the code or a way to improve it. Thank you?
sll * pop(sll *head, int *rt) {
if(head == NULL) {
// *rt = NULL;
return NULL;
}
*rt = head->value;
sll * curr = head->next;
free(head);
return curr;
}