main.cpp
/// <summary>
/// Deletes the last node within the singly linked list.
/// If the last node is also the first (and therefore only) node,
/// the list will be empty after a call to this function.
/// </summary>

Deletes the last node within the singly linked list.
If the last node is also the first (and therefore only) node,
the list will be empty after a call to this function.
Deletes the last node within the singly linked list . If the last node is also the first ( and therefore only ) node the list will be empty after a call to this function .
void deleteLastNode() {
	if (head == NULL) {
		return;
	}
	if (head->next == NULL) {
		free(head);
		head = NULL;
		return;
	}
	struct measurement *secondLastNode = head;
	while (secondLastNode->next->next != NULL) {
		secondLastNode = secondLastNode->next;
	}
	free(secondLastNode->next);
	secondLastNode->next = NULL;
}
void deleteLastNode ( ) { if ( head == NULL ) { return ; } if ( head -> next == NULL ) { free ( head ) ; head = NULL ; return ; } struct measurement * secondLastNode = head ; while ( secondLastNode -> next -> next != NULL ) { secondLastNode = secondLastNode -> next ; } free ( secondLastNode -> next ) ; secondLastNode -> next = NULL ; }
<summary>
Deletes the last node within the singly linked list.
<summary > Deletes the last node within the singly linked list .
// TODO: Implement this function... // Do nothing, if the list is empty. // If the head has no successor, it's the only node. // Remove the singly linked lists only node... // ... and update the head accordingly. // The list contains more than one node. // We now need to find the second last node. // Remove the successor of the second last node... // ... and update the second last node accordingly.