nt readObjects(int& nbObj, int& c, vector &obj, string filein){
// Local variables
istringstream iss;
string parser;
int check = 0;
string nameFile = "F:\\BPP_100_100_0.1_0.7_0.txt";
// File opening
ifstream file(nameFile.c_str(), ios::in);
// File lecture
if (file){
// Number of objects
getline(file, parser);
iss.str(parser);
iss >> nbObj;
iss.clear();
// Capacity
getline(file, parser);
iss.str(parser);
iss >> c;
iss.clear();
// Objects
obj.resize(nbObj);
while (getline(file, parser)){
iss.str(parser);
iss >> obj[check%nbObj];
iss.clear();
check = check + 1;
}
//File closing
file.close();
// Check
if (!(check == nbObj)){
return -2;
}
}
else{
return -1;
}
return 0;
} |