我想遍历数组arithchar中的字符以确定是否有任何输入的字符与它匹配。确定输入中是否包含算术运算符c
我的代码如下所示:
int checkForAO(char password_entered[]);
int main(){
if(checkForAO(password_entered)){
//contains a password with ao
}
else{
//doesnt contain special ao.
}
int checkForAO(char password_entered[]){
int i;
char arithchar[4] = {'+','-','*','/'};
for (i=0; i<strlen(password_entered); i++) {
if (<<<< password_entered[i] contains any character in arithchar array >>>>>>>)) {
printf("\nYour password contain(s) ao.\n");
return true;
}
}
printf("\nYour password didn't contain any ao.\n");
return false;
}
我需要特别帮助的决定我最后的if{}
声明,我试图pseudocoding了我所需要的,但似乎无法推测这一个。
谢谢。
尝试'for'语句而不是'if if语句 – wimh