求大神, 哪里錯了
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int ch;
FILE * fp;
char fname[50];
printf("Please enter file nmae to open: ");
while(scanf("%s", fname)== 1)
{
int count = 0;
fp = fopen(fname, "r");
if (fp = NULL) //地址為空,文件不存在 —失敗
{
printf("Failed to open the file.\n");
exit(1);?
}
while((ch = getc(fp)) != EOF)
{
putchar(ch);
++count; //統(tǒng)計字符數(shù)?
}
printf("\ncharacter count = %d\n", count);
printf("Please enter next file nmae to open: ");
fclose(fp);
}
return 0;?
}
無法顯示文件內(nèi)容,還有統(tǒng)計的字符數(shù)目, 這個一直輸出0,哪里錯了
2017-02-07