我试图通过按任意键随时退出循环。我已经尝试了下面的代码,但它无法完成。得需要你的帮助。先感谢您。我正在使用 C-Free 5.0。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
    int b=0, i;
    int seconds;
    printf("\nEnter number of seconds : ");
    scanf("%d", &seconds);
    while (b==0)
    {
        for(i=1;i<=seconds;i++)
        {
            time_t end = time(0) + 1;
            while(time(0) < end)
            ;
            seconds -= 1;
            printf("Number of seconds left : %d\n", seconds);
            b=kbhit();
        }
        if(seconds == 0)
        {
            exit(0);
        }
    }
    printf("Number of remaining seconds left : %d\n", seconds);
}