thanks quzah. I changed it a little but I am still having trouble with it.
Assuming Header struct looks like this
Code:
typedef struct
{
struct node_d *psHead;
struct node_d *psTail;
struct node_d *current_node;
int node_count;
}Header;
I figured this would work, but doesn't. Can you see any flaws in it ?
Code:
int Search_List(Header *psList, int z)
{
int x;
char answer[40], compare[40];
printf("\n\nWhat City or Zipcode would you like to search for?");
scanf("%s",&answer);
if (isdigit(answer[0]) != 0)
{
//search for zip
psList->current_node = psList->psHead;
for(x=0;x<psList->node_count;x++)
{
strcpy(compare, psList->current_node->zipcode);
if(strcmp(answer, compare)== 0)
{
system("cls");
printf("\nThe Zipcode was found with %d comparisons",x+1);
printf("\nZipcode = %s City = %s State = %s",psList->psHead->zipcode, psList->psHead->city, psList->psHead->state);
printf("\nPopulation = %d Longitude = %-.2f latitude = %-.2f\n",psList->psHead->population, psList->psHead->longitude, psList->psHead->latitude);
x=z;
}
else
{
psList->current_node = psList->current_node->next;
}
}
printf("\nRecord was not found\n");
}