I'm trying to hash the contents of a file line by line. The procedure i have thought was to get the last character of the string and then hash that last character but it,s giving me problems. any help would be appreciated.
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();
}
 
    