*Edit* Ignore this portion, current issue is at post 5.
I'm attempting to extract info from a text file and load it into a linked list. The problem I'm running into is that I'm trying to only have 3 members for the struct, but when I try to read in the name, I'm having to split it up due to a white space in between.
The text file is formatted as such:
Last_name, First_name
ID_Number
Address
How do I get the program to read in "Doe, John" as name. I want it to store the information just like it's read, i.e. I don't want it to remove the white space, rather just continue reading until it reaches a new line.
I'll also have the same problem when it gets to address.
Also, when I get there, I'm going to want to be able to search within the linked list by a particular member, say, name. But I'm going to only want to search using either first_name or last_name. I assume there will be a way for me to just search through the member type, at which point I'll have to tell it to stop searching when it reaches ',' -- yes?
Here's what I've got so far:
Code:
struct node
{
char name[30];
char lastName[30];
int ID;
char address[50];
node *next;
};
int main(int argc, char *argv[])
{
ifstream inFile ("A1.txt");
node *root;
root = new node;
root->next = 0;
inFile >> root->name;
inFile >> root->lastName;
inFile >> root->ID;
inFile >> root->address;
cout << root->name << endl
<< root->lastName << endl
<< root->ID << endl
<< root->address << endl;
inFile.close();