Suppose I would like to count characters in some mFile like this:
while((c = getc(mFile)) != EOF){
chars[c]++;
}
If I try to show them:
for(int f=0;f<256;f++) {
if(isprint(f) && chars[f]>0)
cout << (char)f << " " << (int)chars[f] << endl;
}
All characters print fine. But if I do
cout << " " << (int)chars[32] << endl;
Then it doesn't print the number... just some large int, I guess, because it's negative. What am I doing wrong? Does getc break on, or not count spaces?
Thanks