All pastes #467953 Raw Edit

Unnamed

public cpp v1 · immutable
·published 2007-05-02 20:29 UTC
rendered paste body
struct node{    /* Char* definitions */	char * location;	char * rating;	char * foodtype;    /*node definitions */	node * nextFoodtype;	    node * nextRating;};        class ManipInfo{    public:        ManipInfo(); //Constructor        ~ManipInfo(); //Destructor                /*Functions */        int insert(char* locationInput, char *foodtypeInput, char* ratingInput); //Add information to the linear linked list        int retrieve(char* searchWord, char* returnInfo, int caseNum); //Retrieve information from the linear linked list        int remove(char* searchWord); //Remove information from the linear linked list        int display(int & selectDisplay); //Display all information in the linear linked list        int destroy();    private:        /*Private nodes */        node * head;        node * current;        node * temp;        node * previous;};---------------------int ManipInfo::insert(char* locationInput, char *foodtypeInput, char* ratingInput) //This function inserts information into the linked list{    ManipInfo manInfo;    	node *temp;	/* Allocate memory for new linked lists */	current					= new node;	current->location		= new char[strlen(locationInput) + 1];	current->rating			= new char[strlen(ratingInput) + 1];	current->foodtype		= new char[strlen(foodtypeInput) + 1];    /* Set the initial next pointers to NULL */	current->nextFoodtype	= NULL;	current->nextRating		= NULL;	/* Copy input */    strcpy(current->location, locationInput);	strcpy(current->foodtype, foodtypeInput);    strcpy(current->rating  , ratingInput);    	/* If this is the first entry, just add it and return */	if(!head)    {		head = current;	}	    else     {        /*Jump through and set our new current */        for(temp=head; temp->nextFoodtype; temp=temp->nextFoodtype);        temp->nextFoodtype=current;                /*Jump through and set our new current */        for(temp=head; temp->nextRating; temp=temp->nextRating);        temp->nextRating=current;    }        /*Just let the application know everything went well */	return 1;}