我编写了一个程序来尝试使用C中的2D数组打印包含用户输入图形表示的2D表。我编译并运行该程序,但无论我按下Return或Ctrl + D进行EOF多少, getchar似乎没有像预期的那样按照循环中的指令。我在这里做错了什么?
int main()
{
/*ignore these comments, they are outdated todo lists*/
/* make vars init here, change for to while */
/* finish printing */
int c;
int i, sec, other;
char ndigit[3][8];
while((c = getchar()) != EOF) {
if (c == '\n' || '\t' || ' ') {
for(i = 0; i < 63; ndigit[1][i] += 1);
;
}
else if (c >= '0' || c <= '9') {
for(sec = 0; sec < 63; ndigit[2][sec] += 1)
;
}
else
for(other = 0; other < 63; ndigit[3][other] += 1)
;
}
for (i = 0; i <= 3; ++i)
for (sec = 0; sec <= 8; sec++)
printf("%s\n", ndigit[i][sec]);
}