修改6.2应用案例代码,要求用getchar函数代替getc函数实现相同功能。
【案例分析】
getchar()与getc(stdin)等效,直接替换即可。
【参考代码】
#include<stdio.h>
main()
{ int c,n=0,s=0;
while((c=getchar())!='\n')
if(c>=48&&c<=57)n++;
else if((c>=65&&c<=90)||(c>=97&&c<=122))s++;
printf("数字%d个,英文字母%d个",n,s);
}
评论列表