I know the i++ means return i and then increase 1, and ++i means increase 1 then return i. In this code:
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;
}
In this loop, when I move i++ to "while (word[i++] != '\0')" the output will print out info that
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
When I move ++i to "while (word[++i] != '\0')", the output will ignore the first one char. it shows:
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
How could that happen?