gpt4 book ai didi

c - 如何在循环中连续打印变量并在 linux 下的 C 中按一下转义键终止?

转载 作者:IT王子 更新时间:2023-10-29 00:38:38 24 4
gpt4 key购买 nike

<分区>

请在下面找到代码部分。我想在循环中连续打印变量的当前值。一旦我按下转义键,循环就必须终止。这里的问题是执行在 getchar 函数处停止。但我希望它继续打印变量的值,直到我按下退出按钮。

do
{
vUpdateVariable(); // routine to update the current value of variable
printf("Value is %f\r", fVariable);
ucKey = getchar();
usleep(1000);
}while (ucKey != 0x1B);

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com