Guest User

GetAllFileWeights(

a guest
Dec 30th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. int GetAllFileWeights(char * GFWname )
  6. {
  7.     int wread;
  8.     string line;
  9.     ifstream myfile;   
  10.     //.
  11.  
  12.     myfile.open (GFWname, ios::in);
  13.     if (myfile.is_open())
  14.     {
  15.         wread = 0;
  16.         while ( getline (myfile,line) )
  17.         {
  18.             if( wread < 384 ) {                
  19.                 if( (line.length()) > 8 ) {
  20.                     sWeightsPool[wread] = stod(line);  
  21.                     wread++;
  22.                 }
  23.             }
  24.         }
  25.         myfile.close();
  26.         if( wread > 383 ) {
  27.             return 1;
  28.         } else {
  29.             cout << "Failed to read all 384 weights from disk.";
  30.             return -3;
  31.         }
  32.     }else {
  33.         cout << "Unable to open ";
  34.         cout << GFWname;
  35.         cout << endl;
  36.         return -1;
  37.     }
  38.  
  39.     return 1;
  40. }
Add Comment
Please, Sign In to add comment