Who can help me with a key list in C?

If i understood it right, you want to achieve the requirements by using the program you wrote above.

It possible to re-design it using your own code.

eg : For get()

struct node *get(int key, void *data)
{
    if(*head_ref != NULL)
    {
        key = *head_ref->data;
        return *head_ref;
    }
    else
    { 
        printf("Error in retrieving data from head of list\n");
    }
}

In this way you can use code from your program and modify it slightly to achieve what is asked.
The first node that you visit, if the list does exist- is the head of the list. You are asked to return a pointer to the head of the list and also copy the data in that node into variable ‘key’.
If you are still having trouble, i would suggest you go through linked list concept once more to be sure you won’t have any trouble. You can refer to Youtube to find videos on these concepts.

Leave a Comment