「已注销」 2019-10-06 08:20 采纳率: 50%
浏览 289
已采纳

《C Primer Plus》程序清单12.4无法运行

请各位帮忙看一下为什么不能运行,编译也没有警告和错误

#include <stdio.h>

int units = 0;
void critic(void);
int main(void)
{
    extern int units;

    printf("How many pounds to a firkin of butter?\n");
    scanf("%d", &units);
    while (units != 56);  //程序会卡在这里无法进行
    {
        critic();
    }
    printf("You must have looked it up!\n");

    return 0;
}

void critic(void)
{
    printf("No luck, my friend.Try again.\n");
    scanf("%d", &units);
}
  • 写回答

2条回答 默认 最新

  • threenewbee 2019-10-06 09:21
    关注

    while (units != 56);

    多了一个分号,造成死循环

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?