feof(fp) 的测定,应在刚读完的时候,而不是在读以前。while(1){ fscanf(fp, "%c", &letter); //读if(feof(fp))break; //若EOF 则退出if(letter==one)num++; // 计数 }