问题描述
- 求好心人看看我的code哪里不对
-
这是我写的一个作业的代码,但是每次运行的时候文件无论如何都打不开,但是我的文档已经放进了文件夹里面,现在很无奈不知道怎么办,有好心人能帮忙解答一下吗。。。跪谢#include
#include
#include
#include
using namespace std;
const int MAX_ASCII=127;
const int MIN_ASCII= 0;
const int NUM_ASCII=128;int main()
{
int counter[NUM_ASCII],k;
char char_in;
ifstream encrypted;
string name;
cout << "Enter the input file name:";
cin >> name;
encrypted.open(name.c_str());
if(encrypted.fail())
{
cerr << "The file " << name <<" can not open" << endl;
system("pause");
exit(1);
}
for(k=0;k<NUM_ASCII;k++)
counter[k]=0;
while(encrypted.get(char_in) && !encrypted.eof())
counter[(int)char_in]++;
for(k=0;k<NUM_ASCII;k++);
if(counter[k]!=0)
cout << "ASCII: " << (char)k <<"t, VALUE: " << k <<"t, NUMBER OF OCCURRENCES: " << counter[k] << endl;
system("pause");
return 0;
}
解决方案
控制台报错信息呢????