【发布时间】:2015-07-26 06:59:01
【问题描述】:
我的代码运行良好。但是当我因为这是我第一次在 Luna Eclipse 上尝试调试它并想了解调试过程是如何工作的时,它给了我一个错误提示
*stopped,reason="end-stepping-range",frame={addr="0x00401479",func="main",args=[],file="..\src\Assignment1A.c",fullname ="C:\Users\Sunghee\workspace2\Assignment1A\src\Assignment1A.c",line="37"},thread-id="1",stopped-threads="all"
我不明白这一点,因为当我运行它时它工作得非常好。错误出现在我的第一个 if 语句中,所以在
printf("\n%d + %d =%d", num1, num2, ans);
if (num2 > 0) {
printf("\n%d / %d = %d", num1, num2, num1 / num2);
printf("\n%d %% %d = %d", num1, num2, num1 % num2);
}
else {
printf("\n%d /%d is not allowed", num1, num2);
}
谁能告诉我为什么?我已经研究过了,但是我不明白的所有术语……对我不起作用:p 谢谢!
当我运行它时,它在 Eclipse 中工作。当我逐行调试时,错误发生在上述一行之后。 完整代码:
包括
包括
int main() { 整数 1; //用户输入的第一个数字 整数 2; //用户输入的第二个数字 诠释; //存储数学结果的变量
setbuf(stdout, 0);
printf("Please enter the first integer:\n");
scanf("%d", &num1);
printf("Please enter the second integer:\n");
scanf("%d", &num2);
ans = num1 + num2;
printf("\n%d + %d =%d", num1, num2, ans);
if (num2 > 0) {
printf("\n%d / %d = %d", num1, num2, num1 / num2);
printf("\n%d %% %d = %d", num1, num2, num1 % num2);
}
else {
printf("\n%d /%d is not allowed", num1, num2);
printf("\n%d %% %d is not allowed", num1, num2);
}
printf("\nThe average of %d and %d is %d", num1, num2, (num1+num2)/2);
return 0;
}
所以如果有人可以帮忙,请帮忙!正如我所说,我运行它时没有问题。但是我想知道为什么调试时会出错。出于好奇:D
【问题讨论】:
-
它工作正常直到 printf (...) 但在我的控制台中弹出错误,然后我无法继续调试。
-
你的意思是你的代码可以正常工作,除了在 ecrise???
-
请出示完整代码。