为什么我这个程序运行到fopen语句就结束了?

 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
请按任意键继续. . .

 调试下这一行 file=fopen("text.txt","r");
可能的原因:文件没有找到,你可以用绝对路径,比如file=fopen("c:\\path\\text.txt","r");
权限问题,用管理员权限运行vs,再运行你的程序,文件放在桌面不i要放在根目录