John Swift 15 2005 20000
Andrew Smith 25 2001 25000
I am trying to read in this data into a linked list of data structures as follows:
Expand|Select|Wrap|Line Numbers
- temp = new client;
- head = temp;
- //do
- while(!infile.eof())
- {
- infile >> temp->name;
- infile >> temp->experience;
- infile >> temp->year;
- infile >> temp->desiredsalary;
- temp->next = new client;
- temp = temp->next
- }
- temp->next = NULL; // set last next in the linked list to NULL
- temp = head; // move temp pointer to start of the list
- }
I'm not very good with input / output and strings. Could someone please give me an idea as to how to enter both name and surname from the file into one variable in the structure of the linked list.
I think the getline command has to be used:
Expand|Select|Wrap|Line Numbers
- infile.getline (name);
Thx!