I dont know wats wrong with ur code. But when i executed it myself it worked perfectly except for the fact that it doesnt cound uppercase characters. for that u can use the tolower() function on the characters read from the file and then compare it with c.
Take a look:
CODING:
#include <iostream>
#include <fstream>
//#include <ctype>
using namespace std;
void Character_Freq()
{
ifstream In_File("infile.txt");
char c;
int i,count;
// In_File.open("infile.txt");
cout<<"Characters\tFrequency"<<endl;
if(In_File.is_open())
{
for(i=97;i<=122;i++)
{
count = 0;
c = (char)i;
while(!In_File.eof())
{
if(tolower((char)In_File.get())== c)
{
count++;
}
else
{
//Don't Count
}
}
In_File.close();
cout<<(char)i<<"\t\t"<<count<<endl;
In_File.open("infile.txt");
}
}
else
{
cout<<"\nFile was unreadable";
}
In_File.close();
}
int main()
{
Character_Freq();
return 0;
} Input file was:WiBit was a website
University in Baltimore
Output was:Characters Frequency
a 3
b 3
c 0
d 0
e 4
f 0
g 0
h 0
i 7
j 0
k 0
l 1
m 1
n 2
o 1
p 0
q 0
r 2
s 3
t 4
u 1
v 1
w 3
x 0
y 1
z 0