C语言-统计数字、字母、特殊字符

Action() {

//统计字符019aBcd8***,4,4,3
int i,z,t;
char *str="019aBcd8***";

fun_Count(str,i,z,t);
lr_output_message("存在数字%d 存在字母%d 存在特殊字符%d",i,z,t);//输出000,怎么把值传出来呢?
return 0;
}

fun_Count(char *str,int i,int z,int t){//i整数、z字符、t特殊字符
while(*str!=''){ //换成while(*str++!='',去掉下面的str++,执行结果是3,4,4是怎么回事?)
if(*str>='0'&&*str<='9'){
i++;
//lr_output_message("i=%d",i);
str++;
}
else if((*str>='a'&&*str<='z')||(*str>='A'&&*str<='Z')){
z++;
//lr_output_message("z=%d",z);
str++;
}
else{
t++;
//lr_output_message("t=%d",t);
str++;

}
}
lr_output_message("存在数字%d 存在字母%d 存在特殊字符%d",i,z,t);
return 0;
}

执行结果:

Action.c(31): 存在数字4 存在字母4 存在特殊字符3
Action.c(8): 存在数字0 存在字母0 存在特殊字符0

原文地址:https://www.cnblogs.com/Miss-Elsa/p/7001962.html