是發聲函式,執行後透過主機板喇叭唱出旋律,可以試試下面:
TC 試:
#include
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
nosound();/* stop playing */
void main()
mysound() ;
---------------
VC++ 試:
main()
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
------
wintc 試驗上兩個。
是發聲函式,執行後透過主機板喇叭唱出旋律,可以試試下面:
TC 試:
#include
#include
#include
/* this founction plays sound until hit any key */
void mysound()
{
long freq ;
while(!kbhit()){/* while no keyboard hit, play sound */
for(freq=200L;freq
sound(freq);/*play freq sound*/
delay(200);/*delay 200ms*/
}
}
nosound();/* stop playing */
}
void main()
{
mysound() ;
}
---------------
VC++ 試:
#include
#include
#include
main()
{
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
Sleep(500);
Beep(523,500);
Beep(587,500);
Beep(659,500);
Beep(698,500);
Beep(784,500);
}
------
wintc 試驗上兩個。