I want to increment specific vector elements. I am opening and reading from a file and want to count how many a, b, c and all the way to z I have. I have made a vector with 26 "locations" so that v[0] will have the count of how many a's I have, and so on. But, when I search for the characters in my file, how do I increment v[0] to 1 when I find an 'a'?
void drawStatistics()
{
cout << "Which file will you read from? ";
string iname;
cin >> iname;
ifstream in {iname};
if (!in) error("cant open inputfile ", iname);
vector<int> characterCount[26];
char letter;
while ( inn >> letter )
{
inn >> letter;
letter = tolower(letter);
if ( letter >= 'a' && letter <= 'z' )
{
//I tried doing something like this but I get an error message.
characterCount[letter - 'a']++;
}
}
}