我知道i ++表示先返回i,然后加1,而++ i表示先加1,然后返回i。在此代码中:
int isTotalAlphabetical(char word[]){
int i = 0;
while (word[i] != '\0') {
printf("The %dth is: %d, the char is %c\n", i,isalpha(word[i]), word[i]);
if (!isalpha(word[i])){
printf("now return 0, because the %c is not alpha, it's the %d char\n", word[i], i);
return 0;
}
i++;
}
return 1;
}
在此循环中,当我将i ++移至“ while(word [i ++]!='\ 0')”时,输出将打印出以下信息
The 2th is: 1, the char is p
The 3th is: 1, the char is l
The 4th is: 1, the char is e
The 5th is: 0, the char is
now return 0, because the is not alpha, it's the 5 char
当我将++ i移至“ while(word [++ i]!='\ 0')”时,输出将忽略第一个字符。它显示:
The 1th is: 1, the char is p
The 2th is: 1, the char is p
The 3th is: 1, the char is l
The 4th is: 1, the char is e
那怎么可能?