Advertisement
patryk

loadFromfile

Dec 28th, 2014
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. #include <fstream>
  2. #include <cstdlib>
  3.  
  4. //------------
  5.  
  6.  char buf[100];
  7.     int numberOfTasks;
  8.     fstream plik;
  9.  
  10.     plik.open("100RANDOM.txt", ios::in);
  11.  
  12.     if(plik.good()) {
  13.         plik.getline(buf, 6);
  14.         numberOfTasks = atoi(buf);
  15.  
  16.         for(int i = 0 ; i < numberOfTasks; i++) {
  17.             int machine1_task, machine2_task;
  18.  
  19.             plik.getline(buf, 10, ';');
  20.             machine1_task = atoi(buf);
  21.             plik.getline(buf, 10);
  22.             machine2_task = atoi(buf);
  23.  
  24.             /*
  25.                 TU SOBIE ZROBISZ DODAWANIE DO JAKIEGOS OGOLNEGO CZEGOS
  26.                 ZEBY MIEC LISTE TYCH TASKOW DLA KAZDEJ MASZYNY I  ICH CZASY
  27.             */
  28.         }
  29.  
  30.         while(!plik.eof()) {
  31.             int pauseNumber, machineNumber, timeForPause, whenPauseStart;
  32.            
  33.             plik.getline(buf, 10, ';');
  34.             pauseNumber = atoi(buf);
  35.             plik.getline(buf, 10, ';');
  36.             machineNumber = atoi(buf);
  37.             plik.getline(buf, 10, ';');
  38.             timeForPause = atoi(buf);
  39.             plik.getline(buf, 10);
  40.             whenPauseStart = atoi(buf);
  41.  
  42.             if(timeForPause == 0 && machineNumber == 0 && whenPauseStart == 0) break;    // PO TO BO SIE TWORZY TEN LAMERSKI OSTATNI PUSTY WIERSZ
  43.  
  44.             /*
  45.                 TU SOBIE ZROBISZ DODAWANIE PRZERW DO JAKIEGOS
  46.                 CUDA CO BEDZIE JE PRZECHOWYWAC
  47.             */
  48.         }
  49.  
  50.     } else {
  51.         cout << "Ups...Something went wrong.";
  52.     }
  53.  
  54.     plik.close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement