Hello all, I am having some problems with a LOT of errors, for this small module. Below is my code that I have so far, and the module called, modify causes 85 errors that are all the same - C:\Documents and Settings\ms219548\My Documents\Data\Linked_List.cpp(151) : error C2143: syntax error : missing ';' before '}'
When i comment out that module I only get 17 errors. those i haven't gotten to yet because I was just blown away by 85 errors.
The purpose of the program is to take input from a file and using pointers to store the info and manipulate it depending on the first number on the line.
Here is the full code,
Code:#include<iostream> #include<fstream> using namespace std; fstream instream; struct node; //define the structure of the node typedef node *node_ptr; struct node{ int indicator; char name[20]; int ssnum; char address[25]; int phone; node_ptr next; }; node_ptr list, p, q, prev; void get_node(node_ptr q); void print_list(node_ptr list); void modify(node_ptr list); void delete_info(node_ptr list); bool search(list, prev, p); int main(){ int indicator; node_ptr q; list = NULL; //reads the information in from an external file to a linked list fstream instream; instream.open("linked2.txt", ios::in); while (!instream.eof()) { instream >> indicator; switch (indicator) { case 1: //indicator is 1 bool search(list, prev, p); if (!found) // if the value is not in the list already, insert it { instream >> q->name; instream >> q->ssnum; instream >> q->address; instream >> q->phone; void get_node(node_ptr q); } break; case 2: //indicator is 2 bool search(list, prev, p); if (found) // if the value is already in the list, delete it { void delete_info(node_ptr list); } break; case 3: //indicator is 3 bool search(list, prev, p); if (found) // if the value is found, modify the phone number { void modify(node_ptr p); } break; case 4: //indicator is 4 void print_list(node_ptr list); break; default: break; } } instream.close(); return 0; } void get_node(node_ptr q) { q = new node; q->next = NULL; } //Indicator = 4 then we print out the info to a formatted table void print_list(node_ptr list) { node_ptr p; //get a temporary pointer and initialize it to the p = list; //address of the first node while (p != NULL) //as long as there are more elements in the list { cout << "Name \t SS Number \t Address \t Phone Number \t\n"; cout << "___________________________________________________\n"; cout << p->name <<"\t"; //print out the contents of the data field cout << p->ssnum <<"\t"; cout << p->address <<"\t"; cout << p->phone <<"\t"; p = p->next; //move to the next node } } //HERE IS THE MODULE THAT IS GIVING ME THE PROBLEMS!!!!!!!!! //HERE IS THE MODULE THAT IS GIVING ME THE PROBLEMS!!!!!!!!! //HERE IS THE MODULE THAT IS GIVING ME THE PROBLEMS!!!!!!!!! // //Indicator = 3 then the person's telephone number is to be modified void modify(node_ptr q) { q = p; q->phone = new phone; } //Indicator = 2 then the person's information is to be deleted from the linked list void delete_info(node_ptr q) { q = p; delete q; q = NULL; } //Search routine to determine if information is already in the linked list bool search(list, prev, p) { bool found; prev = NULL; p = list; while ((p!=NULL) && (p->name != name)) { prev = p; p = p->next; if (p == NULL) found = false; //name not found else if (p->name != name) found = false; //name not found else found = true; //name found } return (found); }


Reply With Quote


Bookmarks