How to read in a sentence and insert in to linked list?

Reply

Join Date: Aug 2004
Posts: 8
Reputation: wewe is an unknown quantity at this point 
Solved Threads: 0
wewe wewe is offline Offline
Newbie Poster

How to read in a sentence and insert in to linked list?

 
0
  #1
Sep 27th, 2004
C ++ reading a textfile into linked list

text file:

Humpty Dumpty sat on the wall
Humpty Dumpty had a great fall
all the kings horses and all the kings men
could not put Humpty Dumpty back together again
---------------------------------------------------

the idea is to read in this sentence into a linked list..

i would a ppreciate it if you can post similar codes that read in a sentence..

thanks..

pls help me because my dead line is 2 days away...:-|
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 40
Reputation: coolmel55 is an unknown quantity at this point 
Solved Threads: 1
coolmel55 coolmel55 is offline Offline
Light Poster

Re: How to read in a sentence and insert in to linked list?

 
0
  #2
Sep 27th, 2004
Try something like this! Remember to #include <list>

void Standard::get_list()
{
char filename[16];
char variable;

cout << "Please enter a filename: ";
cin >> filename;

fstream instream(filename);

if(instream.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}

while (instream >> variable)
list1.push_back (variable);

cout << "\nThe contents of your file: \n" << endl;

for (i=list1.begin(); i != list1.end(); i++)
{
cout << *i << " " << endl;
}
}
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 8
Reputation: wewe is an unknown quantity at this point 
Solved Threads: 0
wewe wewe is offline Offline
Newbie Poster

Re: How to read in a sentence and insert in to linked list?

 
0
  #3
Sep 30th, 2004
thank you!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 40
Reputation: coolmel55 is an unknown quantity at this point 
Solved Threads: 1
coolmel55 coolmel55 is offline Offline
Light Poster

Re: How to read in a sentence and insert in to linked list?

 
0
  #4
Sep 30th, 2004
Originally Posted by wewe
thank you!

Not a problem wanted to know if it worked out for you?

Melinda
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC