文件流输出,将输出的字符串进行归类统计
0x00007FFB1A93AFEC (ucrtbased.dll) (HuffMan.exe 中)处有未经处理的异常: 将一个无效参数传递给了将无效参数视为严重错误的函数。
#include
#include
#include
#include
#include
using namespace std;
struct cq
{
char cha;
double quan;
};
int main()
{
int h = 1;
cq shu[60];
int yy=0;
ifstream ifs;
ifs.open("C:\\Users\\86176\\Desktop\\huff.txt", ios::in);
if (!ifs.is_open())
{
cout << "error" << endl;
return 0;
}
string s;
string io;
while (getline(ifs,s))
{
io += s;
}
ifs.close();
cout << "-------" << endl;
if (h == 1)
{
shu[0].cha = io[0];
shu[0].quan = 1;
}
cout << io.size();
for (int j = 1; j size(); j++)
{
int r = 0;
int g = 0;
for (int m = 0; m < j; m++)
{
if (io[j] == io[m])
{
g = m;
r++;
break;
}
}
if (r == 0)
{
shu[h].cha = io[j];
shu[h].quan = 1;
h++;
}
else {
shu[g].quan++;
}
}
for (int z = 0; z < h; z++)
{
cout << shu[z].cha << "+" << shu[z].quan << " ";
}
}
247B+1 e+25 f+1 i+5 n+17 g+19 +2 u+37 p+3 v+8 a+1 c+6 t+17 o+7 s+1 h+1 l+1 r+1 C+16 O+1 V+15 I+1 D+1 -+1 1+6 9+1 d+1 ,+1 Z+1 N+1 m+1 y+1 x+1 F+1 .+2 H+1 q+1
运行到这里会报错
一直在找错误,感觉循环写的没错。
你点“重试”,然后看看堆栈,错误断点在你的代码哪一行