int FileCodingWords(HuffmanCode HC[],CW *cw)//对文件进行编码
{
FILE *file;
int i,j;
file=fopen("text.txt","r");//运行到这里就不行了
printf("1");//检测运行到哪里出错用的
if(file!=0)
{
word=fgetc(file);
for(i=1;word!=cw->c[i]&&i<=cw->n;i++){
}
if(word=cw->c[i]){
for (j=HC[i].start+1; j <=cw->n; j++)
{
printf ("%d", HC[i].code[j]);
}
}
else{
printf("您创建的字符集中此字符的对应编码。\n即将停止编码。\n") ;
return ERROR;
}
while(word!=EOF){
word=fgetc(file);
for(i=1;word!=cw->c[i]&&i<=cw->n;i++){
}
if(word=cw->c[i]){
for (j=HC[i].start+1; j <=cw->n; j++)
{
printf ("%d", HC[i].code[j]);
}
}
else{
printf("您创建的字符集中此字符的对应编码。\n即将停止编码。\n") ;
return ERROR;
}
}
printf("\n") ;
fclose(file);
}
if(file==0)
{
printf("文件打开失败,或是文件不存在。\n");
return ERROR;
}
return OK;
}
文件是存在的,和程序在一个目录下。
到fopen语句就返回异常值结束了:
Process exited after 15.38 seconds with return value 3221225725
请按任意键继续. . .