Reading .txt file problem ?

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Reading .txt file problem ?

 
0
  #1
Mar 7th, 2008
I am trying to read lines from a .txt file and put them to a vector like this but when I run the program, the computer get stuck.
The file is only about 50 lines.
I wonder what could be wrong with this code.

  1. ifstream File("C:\\Gli\\temp\\File1.txt");
  2. std::vector<string> For;
  3. std::string Dummy;
  4.  
  5. while ( File, Dummy, '\n')
  6. {
  7.  
  8. For.push_back(Dummy);
  9. }
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 517
Reputation: Jennifer84 is an unknown quantity at this point 
Solved Threads: 1
Jennifer84 Jennifer84 is offline Offline
Posting Pro

Re: Reading .txt file problem ?

 
0
  #2
Mar 7th, 2008
I just saw that I forgot getline:

  1. while ( getline(File, Dummy, '\n'))
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC