C语言中gechar位置不同导致输出错误

C语言统计字符

#include

int main()
{
int letter=0,blank=0,digit=0,other=0,i;
char ch;

scanf("%c",&ch);

for(i=0;i<=9;i++)
{
    
    if((ch>='a'&&ch<='z') || (ch>='A'&&ch<='Z'))
    {
        letter++;
    }
    
    else if((ch==' ') || (ch=='\n'))
    {
        blank++;
    }
    
    else if(ch>='0'&&ch<='9')
    {
        digit++;
    }
    
    else
    {
        other++;
    }
    ch = getchar();
}

printf("letter = %d, blank = %d, digit = %d, other = %d",letter,blank,digit,other);

return 0;

}
输入样例:
aZ &
09 Az

输出样例:
letter = 4, blank = 3, digit = 2, other = 1
巨佬们,才学C语言不久,我想知道这行代码中的ch = getchar();为什么放在句首时输出的letter = 3,blank = 4,而放在句尾时输出跟样例一样,还有我想问单一个getchar()和ch = getchar()有什么区别,求解答

单独一个getchar()就是从你键盘读取以后字符然后什么都不做,ch=getchar() 是从键盘读取以后字符后赋给ch变量,此时表示将这个字符存储了起来