kening 0 Report post Posted February 18, 2008 aku nak coding yang bleh wat countdown timer..mcm mane?cth output:selesaikan masalah4*3*8=???jwpn: masa anda tinggal lagi 5 saatmasa anda tinggal lagi 4 saatmasa anda tinggal lagi 3 saatmasa anda tinggal lagi 2 saatmasa anda tinggal lagi 1 saatmasa anda tinggal lagi 0 saattamatend Quote Share this post Link to post Share on other sites
Paralys3r 0 Report post Posted February 23, 2008 awak perlu register timer event dengan OS yang awak gunakan.. rasanya standard library takde.. tapi masih boleh buat sendiri lebih kurang :/* clock example: countdown */ #include <stdio.h> #include <time.h> void wait ( int seconds ) { clock_t endwait; endwait = clock () + seconds * CLOCKS_PER_SEC; while (clock() < endwait) {} } int main () { int n; printf ("Starting countdown...\n"); for (n=10; n>0; n--) { printf ("%d\n",n); wait (1); } printf ("FIRE!!!\n"); return 0; }source berasal dari http://www.cplusplus.com/reference/clibrary/ctime/clock.html. Kalau nak platform-specific, bleh rujuk SetTimer (Windows). Kalau guna GNU libc dia ader alarm() atau setitimer() tak silap saya. Quote Share this post Link to post Share on other sites
Admin2 12 Report post Posted February 29, 2008 boleh tanya tak macam mana kita nak end kan program tu? lepas habis timer? Quote Share this post Link to post Share on other sites