Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HubNode *hh = NULL;
- HubNode **head;
- *head = hh;
- Tools::loadHubs(head);
- cout << hh->name; /* HubNodes have a string called "name" */
- void Tools::loadHubs(HubNode **head)
- {
- string line, name, location;
- // headFlights = currFlights = prevFlights = NULL;
- ifstream myfile("Hub.csv");
- if (myfile.is_open())
- {
- while (getline(myfile, line)) {// Omit the Caption Line.
- while (getline(myfile, name, ','))//Get every value in order.
- {
- getline(myfile, location, 'n');
- // cout << line << "n";
- // cout << name << "n";
- // cout << location << "n";
- HubNode::AddHub(name, location, head);
- }
- }
- myfile.close();
- }
- else { cout << "nUnable to open filen"; }
- }
- void HubNode::AddHub(string sname, string slocation, HubNode **head)
- {
- HubNode* newNode = new HubNode;
- HubNode *point;
- newNode->next = NULL;
- newNode->name = sname;
- newNode->location = slocation;
- if (*head != NULL)
- {
- HubNode *curr = *head;
- while (curr->next != NULL)
- {
- curr = curr->next;
- }
- curr->next = newNode;
- }
- else
- {
- point = newNode;
- *head = point;
- }
- }
- int value = 10;
- int *p;
- *p = value;
- HubNode *hh = NULL;
- HubNode **head;
- *head = hh;
- HubNode *hh = NULL;
- Tools::loadHubs(&hh);
- cout << hh->name;
- void HubNode::AddHub(const string& sname, const string& slocation, HubNode **head)
- {
- HubNode* newNode = new HubNode;
- newNode->next = NULL;
- newNode->name = sname;
- newNode->location = slocation;
- while (*head)
- head = &(*head)->next;
- *head = newNode;
- }
- void HubNode::AddHub(const string& sname, const string& slocation, HubNode **head)
- {
- while (*head)
- head = &(*head)->next;
- *head = new HubNode(sname, slocation);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement