Huzzah! Expanding memory abound:

Code:

#include <acknex.c>
#include <litec.h>

typedef struct LList
{
int data;

struct LList *pNext, *pPrev;
} LList;

LList *pStart, *pPtr;

// add a ptr to the linking list
LList *AddPtr(LList *pPrevNode, int data)
{
pPtr = (LList *)malloc(sizeof(LList));

pPtr->data = data;
pPtr->pNext = pPtr->pPrev = NULL;

// does the given node exist
if (pPrevNode == NULL) // no
{
// do we have a starting node
if (pStart == NULL) //no
pStart = pPtr;

} else {
pPrevNode->pNext = pPtr;
pPtr->pPrev = pPrevNode;
}

return pPtr;
}

// find an item in the linking list
LList *FindPtr(LList *pStartNode, int finddata)
{
LList *pCurrentNode;

pCurrentNode = pStartNode;

while (pCurrentNode != NULL)
{
if (pCurrentNode->data == finddata)
return pCurrentNode;

pCurrentNode = pCurrentNode->pNext;
}

return NULL;
}
int main()
{
LList *pFoundNode;

AddPtr(NULL, 10);
AddPtr(pStart, 20);
AddPtr(pStart->pNext, 30);

if((pFoundNode = FindPtr(pStart, 20)) == NULL)
MessageBox(NULL, "Node not found!", "Linking List Test", MB_OK);
else
MessageBox(NULL, "Item Found!", "Linking List Test", MB_OK);

}



I'm a happy programmer now, .

FixxeR


John Dies at the End - One of the best fictional stories online. Join the fight for Internet Freedom