Advertisement
Guest User

czytaj_plik

a guest
Jan 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <fstream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5.  
  6. void Evolution::read_population_file()
  7. {
  8.     ifstream file;
  9.     file.open(pathIN, ios::in);
  10.  
  11.     if (file.good())
  12.     {
  13.         myList<int> m1;
  14.         string line;
  15.         while (getline(file, line))
  16.         {
  17.             istringstream strstrm(line);
  18.             int number;
  19.             m1.clean();
  20.             while (strstrm >> number)
  21.             {
  22.                 m1.Add(number);
  23.             }
  24.             population.Add(m1);
  25.         }
  26.         file.close();
  27.     }
  28.     else
  29.     {
  30.         cerr << "file not good\n";
  31.         throw runtime_error("File not good.");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement