【发布时间】:2016-03-22 16:12:19
【问题描述】:
假设我处于无限循环中,我希望用户以整数形式输入数据。然后数据将被传递给另一个函数以用于其他目的,这个过程将继续进行,直到用户输入 esc 代替数据并且我希望循环在该点中断。我该怎么做?
while(1)
{
printf("enter the data that need to entered\npress esc to exit\n");
scanf("%d",&n);
function(n);
}
我尝试使用 if-else 但如果我将 esc 的 ascii 值作为数据输入,它会退出我不想发生的循环?
【问题讨论】:
标签: loops while-loop infinite-loop exit-code