我知道在同一个例子上还有另一个问题,但针对不同的问题。
这是代码示例:
#include <stdio.h>
/* count digits, white space, others */
main()
{
int c, i, nwhite, nother;
int ndigit[10];
nwhite = nother = 0;
for (i = 0; i < 10; ++i)
ndigit[i] = 0;
while ((c = getchar()) != EOF)
if (c >= '0' && c <= '9')
++ndigit[c-'0'];
else if (c == ' ' || c == '\n' || c == '\t')
++nwhite;
else
++nother;
printf("digits =");
for (i = 0; i < 10; ++i)
printf(" %d", ndigit[i]);
printf(", white space = %d, other = %d\n", nwhite, nother);
}
在我运行 is 并使用 执行程序后,我得到:digits = 0 0 0 0 0 0 0 0 0 0, white space = 0, other = 0。来自 Xcode...
但是在书中他们说“这个程序本身的输出是:digits = 9 3 0 0 0 0 0 0 0 1, white space = 123, other = 345”
你能告诉我发生了什么事吗..tnx。