Plz help with placing node in a data structure
This funtion halts the program. I'm trying to organize a list of nodes full of city data. They have to be in ascending order of Zip code. Any help with this would be great. I've racked my brain and realize it's a very simple problem. Thanks.
Scott
Code:
struct SListHeader{
struct SListNode *psHead;
struct SListNode *psTail;
int iNodeCount;
};
struct SListNode{
char City[41];
char State[3];
char Zip[6];
double Longitude;
double Latitude;
long Population;
struct SListNode *Next;
struct SListNode *Prev;
};
void vAddListNode (struct SListHeader *psList, struct SListNode *psNode)
{
struct SListNode *psNext;
psNext = mallloc (sizeof(struct SListNode));
psList->iNodeCount+1;
if (psNode->Zip > psList->psHead->Next->Zip)
{
psNode->Next = psNext;
psNode->Prev = psNext-Prev;
psNode->Next->Prev = psNext;
psNode->Prev->Next = psNext;
}
}