求求大佬帮忙,孩子快急哭了把啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
3条回答 默认 最新
- CSDN专家-sinJack 2021-12-28 13:07关注
#include <stdio.h> int main() { FILE *fp; int num=0,others=0,chars=0; char ch; fp=fopen("data.txt","r"); if(fp==NULL) { printf("Open file error!\n"); exit (0); } while(1) { if(fscanf(fp,"%c",&ch) != 1) break; if(ch >= '0' && ch <= '9') num++; else if((ch >= 'A'&& ch <= 'Z')||(ch >= 'a'&& ch <= 'z')) chars++; else others++; } fclose(fp); printf("num:%d chars:%d others:%d\n",num,chars,others); return 0; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报