c语言查找空行程序

#include

main(){
FILE *fp;
int space=0;
char str[81];
fp=fopen("filename.txt","rb");
while(1){
fgets(str,80,fp);
if(feof(fp))
break;
if((str[0]=='\r')&&(str[1]=='\n'))
space++;
}
fclose(fp);
printf("\n In file have %d space line.",space);
getch();
}

0 评论: