|
朋友给的一个“到时间会发出声音”程序,如下:
#include <stdio.h> #include <time.h> #include <iostream.h> #include <conio.h> #include <dos.h>
void Make_Sound() { while(!kbhit()) { sound(200); delay(100); nosound(); } }
int main() { struct time t; int hour,min,sec; gettime(&t); printf("The current time is: %2d:%02d:%02d\n", t.ti_hour, t.ti_min, t.ti_sec); cout<<"now set hour:"<<endl; cin>>hour; cout<<"now set minute:"<<endl; cin>>min; cout<<"now set second:"<<endl; cin>>sec; while(1) { gettime(&t); if(hour==(int)t.ti_hour&&min==(int)t.ti_min&&sec==(int)t.ti_sec) break; }; Make_Sound(); return 0; } |
|