Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- printf("State: %s\n", ptemp->state);
- printf("City: %s\n\n", ptemp->city);
- }
- else if (ptemp == NULL)
- {
- printf("The zip code %s was not found.\n", find);
- test = 1;
- }
- ptemp = ptemp->link;
- }
- puts ("\nType 'y' if you would you like to see the entire list");
- puts ("or any other key to continue>>");
- if (ch == 'y' || ch == 'Y')
- {
- test = 1;
- while (test != 0)
- test = pop (pstack);
- }
- }
- }
- int pop (struct node **pstack)
- {
- struct node *temp;
- if (is_empty(*pstack)== 1)
- {
- printf("\nStack is now empty");
- return(0);
- }
- else
- {
- temp = *pstack;
- printf("Zip Code: %s\n", temp->zip_code);
- printf("State: %s\n", temp->state);
- printf("City: %s\n\n", temp->city);
- *pstack = (*pstack)->link;
- free(temp);
- return(1);
- }
- }
- int is_empty (struct node *stack) //test if stack points to NULL
- {
- if (stack == NULL)
- return(1); //if stack does point to NULL return 1 or true
- return(0); //othrewise stack is not empty
- }
- void free_nodes (struct node **pstack)
- {
- struct node *temp; //temp pointer used for free()ing memory
- while (*pstack != NULL)
- {
- temp = *pstack;
- *pstack = (*pstack)->link;
- free(temp); //release popped node's memory back to Operating System
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement