我在這裏有一個代碼,可能會延遲10秒才能繼續,但我想添加一個功能,用戶可以等待延遲或按任意鍵繼續,我知道它不會像delay(10000) || getch();
任何方式做到這一點?「按任意鍵或等待10秒鐘繼續」
#include <stdio.h>
#include <conio.h>
#include <dos.h>
void main(){
clrscr();
printf("Press Any Key or Wait for 10 Seconds to Continue");
delay(10000);
//getch();
}
你可以很好地與線程做到這一點。你對這個知道多少? – Bathsheba
你可以採取一個時間戳,做一個忙等待循環,當一個鍵被按下或一個新的時間戳顯示10s已經通過 – Leeor
結束[如何停用輸入語句一段時間?](http://stackoverflow.com/questions/18289635/how-to-deactivate-input-statement-after-some-time) – alk