1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
//cette fonction ne lit pas dans un fichier mais dans un vector de string.
int File::read(int lineNumber, int & sortie) {
if(!m_lines.empty() && lineNumber < (int) m_lines.size()) {
try {
sortie = atoi(m_lines.at(lineNumber).c_str());
return SUCCESS_READING;
} catch(exception &e) {
cout << "You must clean the file before reading.";
cout << e.what();
return FAIL_READING_CONFIG;
}
} else {
cout << "The container is empty, or the index is out of range." << endl;
return FAIL_READING_CONFIG;
}
} |
Partager