Original Post
the runtime error I get is Run-Time Check Failure #2 - Stack around the variable 'chChount' was corrupted. I cant see anything wrong with what I am doing here can you? here is my code [Edited by - donjonson on March 25, 2006 2:02:39 PM]
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream infile;
string buffer;
char chbuf;
long chCount[256]= {0};
//memset(chCount, 0, 256 * sizeof(int));
cout<<"please entere a filename to analyze: ";
getline(cin, buffer);
infile.open(buffer.c_str(), ios::in);
if(infile.is_open())
{
while(!infile.eof())
{
chbuf = infile.get();
chCount[chbuf]++;
}
for(int i =0;i<256;i++)
{
if(chCount != 0)
{
cout<<char(i)<<": "<<chCount<<endl;
}
}
infile.close();
}
return 0;
}