The main program asks for user input of what ascii decimal value they wish to know the occurrence of in the file.
The problem I'm having is that it seems to ignore special characters and the values required for input are 0, 40, 255 - which are all special characters. So obviously I'm doing something wrong. I just can't figure out where the problem is.
#include <iostream>
#include <string>
#include "ReadFileAsString.h"
#include "asciiwhat.h"
usingnamespace std;
int main ()
{
what ascwhat;
int query;
cout << "What number is you querying?" << endl;
cin >> query;
cout << endl;
ascwhat.numOccurrence(query);
system ("Pause");
return 0;
}
You don't show the code where (a) the file is opened and (b) you find its length.
This little block of code seems central:
18 19 20
int c = MyFile[0];
for(i = 0; i < c; i++)
ascii[MyFile[i]]++;
On line 20 it looks as though MyFile[0] is just one character in the file. But line 18 suggests it is the length of the entire file. Needs some clarification here.