I am attempting to prompt for, and read, one file after another. The following code does not wait for the second file name to be entered and I'm not sure why.
do
{
cout << "Please enter a filename: ";
getline(cin, fileName);
fileStream.open(fileName);
if (fileStream.fail())
cout << "File Not Found!" << endl;
while (fileStream.get(ch))
{
ch = convertToLowerCase(ch);
index = ch - 'a';
counter[index]++;
}
for (int i = 0; i < 26; i++)
{
cout << char(i + 'a') << " occurs " << setw(5) << counter[i] << " times." << endl;
}
cout << "Would you like to read another file: ";
cin >> ans;
} while (ans != 'q' || ans != 'Q');
Ideally, it would process one file, then prompt for another, process it, prompt, etc. until the user chose to quit.