Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. int readFile(double values[][MAX_COLUMNS], int maxRows, string inputFileName){
  2.     ifstream inFile;
  3.     inFile.open(inputFileName);
  4.  
  5.     int rows;
  6.  
  7.     if (!inFile)
  8.         return -1;
  9.     else{
  10.         for (rows = 0; rows < maxRows && !inFile.eof(); rows++){
  11.             for (int cols = 0; cols < MAX_COLUMNS; cols++){
  12.                 inFile >> values[rows][cols];
  13.                 if (inFile.fail() && rows == 0)
  14.                     return 0;
  15.             }
  16.         }
  17.     }
  18.     inFile.close();
  19.     return rows;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement