Why wont my delete name function acualy delete any names?

#include <stdio.h>
#include <stdlib.h>
#include <strings.h>

void add_member(void);
void remove_member(void);
void display_next_member(void);
void display_required_member(void);

struct member_type *seek(struct member_type *, char[], char);
void error_routine(void);

struct member_type
	{
       char m_f_name[30];
       struct member_type *pointer_to_next_record;
	};

	struct member_type *position_ptr = NULL;
	struct member_type *temp_ptr;

main()
	
	{
       int choice;
       
       do
       {
           /*Display menu and get choice */
           printf("\n\nMenu\n\n");
           printf("Add Member to list\t\t\t\t 1\n" );
           printf("Remove Member From List\t\t\t\t 2\n");
           printf("Display Next Member In file\t\t\t 3\n");
           printf("Display Required Member\t\t\t\t 4\n");
           printf("Exit\t\t\t\t\t\t 5\n\n");
           
           printf("Please Select: ");
           scanf ("%d", &choice);
           
           /* Carry out chosen task */
           
           switch (choice)
           {
                case 1  : add_member();
                break;
                
                case 2  : remove_member();
                break;
                
                case 3  : display_next_member();
                break;
                
                case 4  : display_required_member();
                break;
                
				default : printf ("Error Please Rekey");
            }
	     
		} while (choice != 0); 
		/*Finish*/
		return 0;
	} 

void add_member(void)

	{ /*request Space*/
		if (!(temp_ptr = (struct member_type *)
		malloc(sizeof (struct member_type))))
		error_routine();
     
		/* Link New Record Space Into List */
		if (position_ptr == NULL)
		{ /* add first person to the list */
		position_ptr = temp_ptr;
		position_ptr->pointer_to_next_record = position_ptr;
		}
		else
		{ /* Add record to others already in the list */
		temp_ptr->pointer_to_next_record = position_ptr->pointer_to_next_record;
		position_ptr->pointer_to_next_record = temp_ptr;
		position_ptr = temp_ptr;
		}
     
		/*Get Member Details*/
		printf ("\nKey in first name: ");
		scanf ("%s", temp_ptr->m_f_name);
     
	}

void remove_member(void)

	{ 
		char m_f_name[30];
     
		/*get the name of the member to remove*/
		printf("\nName of member to remove?\n");
		scanf ("%s", temp_ptr->m_f_name);
     
		if(!(temp_ptr = seek(position_ptr, m_f_name, 'P')))
		{
		printf ("\nMember Dosnt Exsist\n");
		return;
		}
     
		position_ptr = temp_ptr;
     
		if (position_ptr == position_ptr->pointer_to_next_record)
		{/*remove only Record from the list */
            free(position_ptr);
            position_ptr = NULL;
		}
		else
		{
         /* Remove record if others in list */
         temp_ptr = position_ptr->pointer_to_next_record;
         position_ptr->pointer_to_next_record = temp_ptr->pointer_to_next_record;
         free(temp_ptr);
		}
	}

void display_next_member(void)

	{
		position_ptr = position_ptr->pointer_to_next_record;
		printf( "\n%s", position_ptr->m_f_name);
	}

void display_required_member(void)

	{
		char member_name[30];
		/*Get name of member to display*/
		printf("\nName of member to find\n");
		scanf("%s", member_name);
     
		/* Search List */
		
		if (!(temp_ptr = seek(position_ptr, member_name, 'C' )))
		{
        printf("\nStudent Not In List\n");
        return;
		}
		
		/*Display Record*/
		
		printf("%s\n", temp_ptr->m_f_name);
		
	}

	struct member_type *seek(struct member_type *start_ptr, char name_required[],
	char ind)
	{ 
		struct member_type *item_ptr, *previous_item_ptr;
		
		/*set item to search*/
      item_ptr = start_ptr;
      
		/*Carry out search*/
        do
        { /*Move to next Record*/
          previous_item_ptr = item_ptr;
          item_ptr = item_ptr->pointer_to_next_record;
          
          /*Check name against required name*/
          if (!(strcmp(name_required, item_ptr->m_f_name)))
			{ /*Item found - Return Pointer*/
				if (ind == 'C')
				return(item_ptr);
				else
				return(previous_item_ptr);
			}
        }while (item_ptr != start_ptr);
		/*Item not Found*/
        return(NULL);
	}          

void error_routine(void)

{
     printf ("\nInsufficient Memory\n");
}

Any ideas? :/

very simple u r calling char m_f_name[30] inside ur remove member function..... n u r not returning anything to the main function..... so, watever is done inside the remove function doesn't link to the main function.... beside, in every function u r doing wrong work..... u r not giving anything, n u r not getting anything..... call m_f_name[30] in main function..... then use call by reference to change the values in the local functions...... i hope it will work then... cheers :)

This article has been dead for over six months. Start a new discussion instead.