When I try this code I get Process returned -1073741819
(0xFFFF FFFF C000 0005).
I need to compute the Frequency of a Character in a text.
I think that problem with the array.
What do you think?
#include <bits/stdc++.h>
int main() {
setlocale(LC_ALL, "Russian");
int freq[256];
std::ifstream inFile;
char ch;
inFile.open("abc.txt");
for (int k = 0; k < 256; k++) {
freq[k] = 0;
}
ch = inFile.get();
while (ch != EOF) {
ch = toupper(ch);
freq[ch]++;
ch = inFile.get();
}
// Print the output table
std::cout << "Letter frequencies in this file are as follows." << std::endl;
for (char ch = 'А'; ch <= 'Я'; ch++) {
std::cout << ch << ": " << freq[ch] << std::endl;
}
return 0;
}