C语言文件程序设计读取文件失败

明明要打开的文件和我写的程序在一个文件夹里但就是打开失败,为什么,怎么办

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    char ch;
    int letter=0,digit=0,other=0;
    FILE*fp;
    if((fp=fopen("f1.txt","r"))==NULL){
        printf("File open error!\n");
        exit(0);
    }
    while(ch!=EOF){
        ch=fgetc(fp);
        if(ch>='0'&&ch<='z'||ch>'A'&&ch<='Z'){
            letter++;
        }
        else if (ch>='0'&&ch<='9'){
            digit++;
        } 
        else{
            other++;
        }
    }
    printf("letter=%d,digit=%d,other=%d\n",letter,digit,other);
    if(fclose(fp)){
        printf("Can not close the file!\n");
        exit(0);
    }
}

要看是命令行方式执行、集成环境执行,集成环境执行IDE会有目录设置,exe和c文件可能不在一个目录,具体要看环境设置,命令行方式执行则不存在这个问题。