gpt4 book ai didi

c - K&R 代码在 VS2012 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 06:25:28 25 4
gpt4 key购买 nike

<分区>

这是来自 K&R,它应该计算数字、空格等。我编译得很好,但当我运行时,我只得到一个空白屏幕,我所能做的就是输入。这行不通是因为 C 语言已经过时了吗?

#include <stdio.h>

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);
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com