if判断的条件是真,却不执行if块中的代码什么原因,前面输出的都是0,其他输出的是总字符数,为为什么

#include

void w()
{
char a[3000]; int b[] = { 0,0,0,0,0 };

char c;
int i = 0, j = 0;
while ((c=getchar())!='#')
{
a[i] = c;
i++;
if (a[i] <= 'z' && a[i] >= 'a' || a[i] <= 'Z' && a[i] >= 'A'){
if (a[i - 1] != 0) j++;
}
else if (a[i] == 32) b[1]++;
else if (a[i] >= 48 && a[i] <= 57) b[2]++;
else if (a[i] == '\n') b[3]++;
else b[4]++;
}
printf("zhimu shuzhi duanluo qitafuhao\n");
printf("\n");
for (i = 0; i < 5; i++)
{
printf("%-6d", b[i]);
}
}

int main()
{
w();


问题解决后请采纳。

// Q950851.cpp : Defines the entry point for the console application.
//

#include <stdio.h>

void w()
{
char a[3000]; int b[] = { 0,0,0,0,0 };

char c;
int i = 0, j = 0;
while ((c=getchar())!='#')
{
a[i] = c;

if (a[i] <= 'z' && a[i] >= 'a' || a[i] <= 'Z' && a[i] >= 'A'){
//if (a[i - 1] != 0) j++;
    b[0]++;
}
else if (a[i] == 32) b[1]++;
else if (a[i] >= 48 && a[i] <= 57) b[2]++;
else if (a[i] == '\n') b[3]++;
else b[4]++;
i++;
}
printf("zhimu shuzhi duanluo qitafuhao\n");
printf("\n");
for (i = 0; i < 5; i++)
{
printf("%-6d", b[i]);
}
}
int main()
{
w();
}