I'm going crazy. I've been trying to a linked list of a struct (which stores some strings and a character) however I've had no luck. It's just not working and I've been working on this for hours on end.
Note: StorePtr is a pointer to the Store struct (which stores the head category) and cPtr is an item (with values already set) that I want to add to the end of the list.
The insert code is as follows:
void insert(StorePtr *store, CategoryPtr *cPtr)
{
CategoryPtr previousPtr;
CategoryPtr currentPtr;
(*cPtr)->nextCategory = NULL;
currentPtr = (*store).headCategory;
if (cPtr != NULL)
{
while (currentPtr != NULL)
{
previousPtr = currentPtr;
currentPtr = currentPtr->nextCategory;
}
if ((*store).headCategory == NULL)
{
(*store).headCategory = *cPtr;
currentPtr = *cPtr;
}
else
{
currentPtr = *cPtr;
previousPtr->nextCategory = currentPtr;
}
}