O'Reilly logo

Just Enough C/C++ Programming by Guy W. Lecky-Thompson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Linked List

To use the linked list, you just need to keep a track of the first node in a variable, commonly known as the head of the list:

sNode * oHead;

The first function that you need to define will initialize an sNode structure so that it can be added to the list—either as the oHead or at the end of the list.

Code Sample 13.2: Example Linked List Node Initialization

Because you know what data the sNode stores, you can define the function accordingly:

void InitializeNode ( sNode * oNode,
       char * szName, char * szValue)
{

    // Set the oNext member to NULL
    oNode->oNext = NULL;

    // Copy the data
    strcpy ( oNode->oParameter.szParameter,
        szName);

    strcpy ( oNode->oParameter.szValue,
        szValue);

}

As you parse the parameters, each pair is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required