Question: How would I code this function in C? This is what I have currently. Apparently I'm missing a few cases like if we were to
How would I code this function in C?
This is what I have currently. Apparently I'm missing a few cases like if we were to delete the first node in the list


int deleteState (StateListNode **list, char *name) Delete the record from the list having a name that matches the specified name. If there isn't one, then just return 1. Otherwise, delete the record from the list and return 0. Free the memory (using free()) associated with the node that you delete. You do not have to (and should not!) free the memory for the name field of the list record that you free. typedef struct StateListNodeStruct { int population; char name [MAX_STATE_NAME_LENGTH]; struct StateListNodeStruct *next; } StateListNode; int deleteState(StateListNode **list, char *name) { StateListNode *deleteSelectStateNode: StateListNode *prevNode; prevNode=NULL; while (*list != NULL) { if (strcmp(deleteSelectStateNode->name, name) == 0) { free(deleteSelectStateNode); return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
