下面那段程序为什么运行不了,它是为了实现什么功能

#include <stdio.h>
int main()
{
FILE *fpd1, *fpd2;char ch;
fpd1= fopen( "d1.dat", "r" );
fpd2= fopen( "d2.dat", "w" );
while ( fscanf( fpd1, "%c", &ch ) != EOF )
if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
fprintf( fpd2, "%c", ch );
fclose( fpd1 );
fclose( fpd2 );
return(0);
}

修改如下,见注释,供参考:

//这段代码的功能是:将 d1.dat 中保存的文件信息,
//把其中大小写英文字符复制保存到文件 d2.dat 中。

#include <stdio.h>
int main()
{
    FILE *fpd1, *fpd2; char ch;
    fpd1= fopen( "d1.dat", "r" );
    fpd2= fopen( "d2.dat", "w" );
    if (fpd1 != NULL){  //修改
        while ( fscanf( fpd1, "%c", &ch ) != EOF )
              if(ch>='A'&&ch<='Z'||ch>='a'&&ch<='z')
                 fprintf( fpd2, "%c", ch );
        fclose( fpd1 );
    }
    else{    // 修改
        printf("Open file fail!\n");
    }
    if(fpd2 != NULL)//修改
       fclose(fpd2);
    system("pause");
    return(0);
}

查一下fopen函数就知道了