So I always seem to encounter this error. I usually find some odd hackish fix for it but this time I'm having too much trouble. I'm basically trying to make a program which corrects words the user types in (similar to that of any modern phone). The function I'm posting below is an attempt to make a vector of vectors. I am associating every letter with it's neighbor keys. For example...
If the user types in the letter 'A', I want a vector with the value 'A' to hold every letter that the 'A' key touches (Q, W, S, and Z). Every time I compile I get a subscript error. Any help would be appreciated.
vector< vector<string> > letterNeighbors; // VECTOR OF VECTORS
ifstream fin("iPhone_keyboard.txt"); // IPHONE KEYBOARD LIST
while ( fin ) // WHILE THE CONSOLE CAN TAKE INPUT
{
char templateLetter; // FIRST LETTER
string neighborLetter; // NEIGHBORING LETTERS
fin >> templateLetter; // GETS THE FIRST CHARACTER OF THE LINE (TEMPLATE)
getline(fin, neighborLetter); // GETS THE STRING OF CHARACTERS NEXT TO IT (NEIGHBORS)
int neighborSize = neighborLetter.size(); // USED TO REFERENCE NUMBER OF ITERATIONS FOR LOOP
int i = 0;
while ( i < neighborSize )
{
letterNeighbors.resize( 123, vector<string> (neighborSize) ); // RESIZES VECTOR
letterNeighbors[templateLetter][i] = neighborLetter.substr(i); // MAKES A VECTOR WITH THE TEMPLATE LETTER AND GRADUALLY ADDS NEIGHBORS
i++;
}
}