How to get string that contains whitespace from .txt file and insert the data into linked list?

I'm using class and object and my data in "realestate.txt".I want to display my list but the output cannot display after the data that contain whitespace. I used getline before, but this method become worst because output totally will not come out. Second, I used skipws or noskipws but both still not work. Someone know how to solve this problem?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void u::loaditem()
{
	ifstream infile;                     //read file
	infile.open("realestate.txt");

	if(infile.fail())                    //if the file doesn't exist
	{
		cout<<"Error"<<endl;
		exit(1);
	}
	node* tt= new node;
	int i=0;
	string zz;
	while(!infile.eof())
	{
		while(infile>>tt->data>>tt->type>>tt->add)
		{
			cout<<"\n"<<tt->data<<endl<<tt->type<<endl<<tt->add<<"\n";		
			tt->next=start;
			start=tt;
		}
	}
	infile.close();
}
Last edited on
Not enough information.

You haven't shown us what u and node look like, nor what your data file looks like,.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.

Last edited on
Topic archived. No new replies allowed.