Я пытаюсь получить sh содержимое файла построчно. Процедура, которую я думал, заключалась в том, чтобы получить последний символ строки, а затем получить sh этот последний символ, но это вызывает у меня проблемы. любая помощь будет принята с благодарностью.
int HashTable::hashFunction(string key) {
char last = key[14]; //--->>!!!! the problem happens here where an out of range error pops up
///although the string passed is 16 characters long
int ila = int(last) - 48; //CONVERT LAST CHARACTER TO INTEGER
return ila % hashGroups;
}
void HashTable::read_from_file() {
fstream myfile;
string input, pass, account number;
myfile.open(address1.c_str(), ios::in);
while (!(myfile.eof())) {
getline(myfile, account number, ',');
getline(myfile, pass, '\n');
int hashValue = hashFunction(account number);
}
myfile.close();
}