项目未编译,Code :: Blocks中没有警告或错误

时间:2014-12-02 21:19:49

标签: c codeblocks antivirus

我将阅读 C编程:现代方法(KN King)这本书,我在第2章。我几乎完成了每一项练习和计划,但是我遇到了#7计划的麻烦

基本上,它会要求您编写一个计算特定金额所需的最低美元金额的程序。我已经编写了程序,它适用于20,10,5和1的账单。但如果我复制部分代码以便用50美元的账单,那么该文件就不会编译。

这是我的代码:

int x, num, rest ;
printf("Insert amount to pay: ");
scanf("%d", &x);
printf("You will use the least amount of bills if you pay like so: \n");

num = x / 50;
rest = x - num * 50;
printf("$%d bills: %d\n", 50, num);

/*
num = rest / 20;
rest = rest - num * 20;
printf("$%d bills: %d\n", 20, num);
*/

num = rest / 10;
rest = rest - num * 10;
printf("$%d bills: %d\n", 10, num);

num = rest / 5;
rest = rest - num * 5;
printf("$%d bills: %d\n", 5, num);

num = rest;
printf("$%d bills: %d\n", 1, num);

return 0;

该程序运行正常,直到我尝试使用我注释掉的部分(它是其他块的副本,但例如使用数字20而不是10)。

编译器没有提供任何警告或错误,它只是不会编译。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我的问题的解决方案完全不是C相关的,因为代码确实编译并尝试运行。

事实证明我的防病毒程序阻止了.exe表单运行或类似的东西。我不知道它会如何以及为什么会这样做,但确实如此。因为我禁用了#Avast Free Antivirus"代码就像一个魅力。

感谢Wather Vane测试我的代码。你让我相信我还没有疯狂:)

相关问题