上古卷轴5盗贼公会大师:如何让这个C程序可以按 X 键退出?

来源:百度文库 编辑:高校问答 时间:2024/04/29 12:32:36
这个程序会一直走下去, 如何让他可以按 X 键退出呢?

#include <stdio.h>
main()
{

float x, totaal = 0.0;
for (x =0.0; x != 0.9; x += 0.1)
{ /*slechtetest*/
totaal += x;
printf("x = %f,lopendtotaal= %f\n",x, totaal);
system("pause");
}
}
请说的详细点。 把原程序复制过去。在把要修改的地方加进去。 谢谢

#include <stdlib.h>
...
scanf("%c",&ch);
if(ch=='X'||ch=='x')
exit(0);
...

scanf("%c",&ch);
if(ch=='X'||ch=='x')...