c code, works on linux, crashes on windows

From: Jerry Gaspard (jgaspard99_at_hotmail.com)
Date: 02/27/05


Date: Sun, 27 Feb 2005 19:01:45 GMT


/****************************************
  * *
  * Module: delete_node *
  * *
  * Purpose: deletes a node from list *
  * returns the pointer to the *
  * new list. *
  * *
  ****************************************/

agent * delete_node(agent *start_list)
{
        int badge;
        agent *temp = start_list;
        agent *current = start_list;

        printf("Badge # of agent to delete: ");
        scanf("%d", &badge);

        while(current != NULL)
        {
                if(badge == current->badge) <----windows bombs here
                {
                        //Node is first in the list
                        if(current == start_list)
                        {
                                start_list = start_list->next;
                                free(current);
                        }
                        //Node is in the middle or end of the list
                        temp->next = current->next;
                        free(current);
                }
                temp = current;
                current = current->next;
        }
        printf("Agent: %d deleted\n", badge);
        return start_list;
}

that code will run perfect on linux when compiled but under windows
crashes at the line with the arrow, i am lost as to what is causing it.
any help would be great.



Relevant Pages